Results 1 to 2 of 2
  1. #1
    timpepu is offline Novice
    Windows XP Access 2003
    Join Date
    May 2009
    Posts
    13

    Running excel macro from access

    Hi !

    I am running excel macro from access , everything goes almoust fine but after the excel macro has runned there goes an Run-time error 440 Automation error in Access VBA an it stop marked red bellow , wha goes wrong ?

    Private Sub Command35_Click()
    Dim XLApp As Object
    ' Open the XLS fle, make it visible, get control and run a macro called muotoilu
    Set XLApp = CreateObject("Excel.Application")
    With XLApp
    .Application.Visible = True
    .UserControl = True
    .Workbooks.Open "thy2.xls" "After opening excel macro it make some settings and save and close the excel file"
    .Application.Run "muotoilu"
    XLApp.Close
    End With


    End Sub

    Br Timo
    Last edited by timpepu; 02-24-2010 at 07:31 AM. Reason: more details !

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Try this code. Note the excel macro is located in the Module1 of Test.xls file. (Test.xls!Module1.muotoilu)


    Private Sub Command35_Click()
    Dim XLApp As Object
    Set XLApp=CreateObject("Excel.Application")
    XLApp.Workbooks.Open Application.CurrentProject.Path & "\Test.xls"
    XLApp.Application.Visible = True
    XLApp.Run "Module1.muotoilu"
    XLApp.ActiveWorkBook.Save
    XLApp.Application.Quit
    Set XLApp=Nothing
    End Sub

    If this solves your problem please mark this thread solved.

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

Similar Threads

  1. Replies: 20
    Last Post: 02-17-2010, 12:12 PM
  2. Running a VB function in a Macro
    By JuuJuu in forum Access
    Replies: 1
    Last Post: 10-27-2009, 02:50 AM
  3. Replies: 2
    Last Post: 09-30-2009, 09:40 AM
  4. Convert Excel Macro to Access Query
    By crownedzero in forum Queries
    Replies: 1
    Last Post: 06-22-2009, 02:13 PM
  5. Replies: 0
    Last Post: 05-07-2009, 02:32 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