Running a Macro from hidden Workbook

L

Lance Hoffmeyer

I am running a app (SPSS) that does some Excel manipulations.

I have an Excel WOrkbook called macros.xls that opens up
hidden whenever Excel is started.

Running objExcel.App.Run "Macro" does not work while macros.xls
is hidden. If I unhide macros.xls then the line does work.

Is there a way to Run this macro without unhiding macros.xls
every time?

Lance
 
D

Dave Peterson

Visibility isn't a problem in xl2002.

This worked for me (started in MSWord):

Option Explicit
Sub testme01()

Dim objExcel As Object
Dim objWkbk As Object

Set objExcel = CreateObject("excel.application")
objExcel.Visible = True

Set objWkbk = objExcel.workbooks.Open("C:\my documents\excel\macros.xls")
objExcel.Run objWkbk.Name & "!macro"
'this worked, too:
'objExcel.Application.Run objWkbk.Name & "!macro"

End Sub

And my macros.xls was a hidden workbook.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top