Results 1 to 2 of 2
  1. #1
    dcgrove is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Dec 2011
    Posts
    3

    Execute Excel Macro from Access failing

    Hello, I am trying to run the code below in my access 2007 database to start an excel macro. However, I need to make some changes to it that far exceed my applicable knowledge. The changes are below:



    1. The macro currently only runs correctly when Excel is not running and the Personal.XLSB workbook is closed. I need theo macro to be smart enough to open Personal.xlsb if needed, or run the code if it is already open.

    2. The Macro that is built in Excel VBA opens several workbooks makes changes to them, then closes some and leaves some open and send a couple of emails. The Access VBA closes excel completely and crashes if I try to remove this line
    Code:
    xlsApp.Quit
    How do I keep the Access VBA from closing excel?

    3. I currently have the path hardcoded to my personal.xlsb, however I need this to be able to run from any one of my colleagues computers so I would like the path to the personal.xlsb workbook be relative. I will be copying the appropriate excel macros to my colleagues Personal.xlsb prior to deploying this.

    Code:
    Sub RunChangetexttonumber()
    
    
    Dim xlsApp As Excel.Application
    Dim xlswkb As Excel.Workbook
    Set xlsApp = CreateObject("Excel.Application")
    Set xlswkb = GetObject("C:\Users\udcg012\AppData\Roaming\Microsoft\Excel\XLSTART\PERSONAL.XLSB")
    
    xlsApp.Application.Run "PERSONAL.XLSB!Changetexttonumber"
    
    xlsApp.Quit
    End Sub

    Thank you for any help you can contribute!

    Clayton Grove
    Last edited by dcgrove; 12-21-2011 at 03:05 PM.

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I haven't used Access to run Excel code for a long time. Maybe one of these sites will help you:

    http://www.accessmvp.com/KDSnell/EXCEL_MainPage.htm

    http://www.fontstuff.com/index.html

    http://www.meadinkent.co.uk/contactme.htm

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

Similar Threads

  1. excel link with access differs from simple export from access
    By M0RDANT in forum Import/Export Data
    Replies: 4
    Last Post: 03-25-2013, 02:43 PM
  2. import excel file to access 2003 yes, access 2007 no
    By stapik in forum Import/Export Data
    Replies: 9
    Last Post: 07-27-2011, 07:09 AM
  3. Run Excel VBA from Access
    By allenjasonbrown@gmail.com in forum Programming
    Replies: 2
    Last Post: 07-07-2011, 09:41 AM
  4. Replies: 1
    Last Post: 08-31-2009, 10:24 AM
  5. Excel to Access
    By college_fellow in forum Programming
    Replies: 0
    Last Post: 12-18-2006, 08:01 PM

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