Solved

Rune macro in Excel from Access

Posted on 2014-03-12
2
323 Views
Last Modified: 2014-03-12
HI,
I am trying to run a macro in an Excel workbook from within Access, using a button on an Access form. Can someone help me in finding out why the following code doesn't work?
'set variables to open Excel
    Dim objXL As Excel.Application
    Dim objWkb As Excel.Workbook
    Dim objSht As Excel.Worksheet
    Dim strFileName As String

strFileName = (GetMyPath() & "Interface2.xlsm")
    Set objXL = New Excel.Application
    With objXL
        Set objWkb = .Workbooks.Open(strFileName, , False, , "thisisthepassword")
                For Each objSht In objWkb.Worksheets
                    objSht.Visible = xlSheetVisible
                Next objSht
                objWkb.Run "Upload2Dbase"
        Set objSht = objWkb.Worksheets("SageDump")
        .Visible = True
        AppActivate objXL.Caption
        objSht.Activate
     End With
     
    'destroy objects
    Set objSht = Nothing
    Set objWkb = Nothing
    Set objXL = Nothing

Open in new window

The error I get is that the Object doesn't support this property or method.
I have searched google and this site for pointers but I'm at a loss.
0
Comment
Question by:Stephen Byrom
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 51

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 39923701
Hi,

ps try

objXL.Run "Upload2Dbase"

Open in new window

Regards
0
 
LVL 1

Author Closing Comment

by:Stephen Byrom
ID: 39923711
Beautifully simple.
Thanks
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question