ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Running a Macro from hidden Workbook (https://www.excelbanter.com/excel-programming/308247-running-macro-hidden-workbook.html)

Lance Hoffmeyer

Running a Macro from hidden Workbook
 
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




Dave Peterson[_3_]

Running a Macro from hidden Workbook
 
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.


Lance Hoffmeyer wrote:

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


--

Dave Peterson



All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com