Results 1 to 9 of 9
  1. #1
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672

    Run Excel Macros in Access

    I coded a project using VBA in Excel. Now they want me to create a form in Access to do the exact same thing. Instead of converting the code to functions etc etc. Can I just call the macros from Excel within Access? The macros are saved in my personal.xls file

  2. #2
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    I wouldn't try that. If the macros are in YOUR personal.xls file, what happens when you no longer work there? Also, how would others run the database if the needed stuff is in your file?

    Build them into Access. You should be able almost copy and paste or export the modules from Excel and import into Access and then modify them as needed to fit from running within Access.
    Last edited by boblarson; 10-13-2011 at 10:54 AM. Reason: added extra part

  3. #3
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    That's a great point! I didn't think about others trying to run the macros. I'll just (as you said) export the modules from Excel and Import into Access.

    Hopefully it will be a smooth transition.

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    There will probably be changes to be made but they are probably going to be minor (most likely).

  5. #5
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Will access recognize commands in my macros such as (just an example code I have)
    Code:
    Set wb = Workbooks.Open

  6. #6
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    No it won't. You would need:

    Code:
    Dim objXL As Object
    Dim wb As Object
     
    Set objXL = CreateObject("Excel.Application")
     
    Set wb = objXL.Workbooks.Open("FileNameAndPathHere")
     
    ' etc.

  7. #7
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Oh and you should read this about how to deal with Excel in Access:

    http://www.btabdevelopment.com/ts/excelinstance

  8. #8
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    Ay yaya! I am entering uncharted territory here! I will def give it a go.

  9. #9
    jo15765's Avatar
    jo15765 is offline Expert
    Windows XP Access 2000
    Join Date
    Nov 2010
    Location
    6 Feet Under
    Posts
    672
    I'll post this in a new thread...

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Macros in Access
    By King in forum Access
    Replies: 1
    Last Post: 09-22-2011, 05:54 PM
  2. Last Record in macros ACCESS 2007
    By jcsuarez in forum Programming
    Replies: 2
    Last Post: 07-09-2011, 06:24 PM
  3. Using Excel macros in Access
    By Lorlai in forum Programming
    Replies: 2
    Last Post: 06-03-2011, 02:01 PM
  4. Access macros
    By mamig in forum Access
    Replies: 2
    Last Post: 01-09-2010, 11:26 AM
  5. Replies: 0
    Last Post: 03-27-2008, 08:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums