Run Macro

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

Hi. I understand I need to open a woekbook in order to run the code within
it (can't run code from a closed workbook). My question is this - Is there
a way to open the workbook in such a way that the user doesn't see it being
opened? I have Application.ScreenUpdating=False, but you still see the
workbook open, then close.

So I guess I'm asking if I can open a workbook in the background without it
automatically being activated? Thanks!
 
Dim appXL As Excel.Application
Dim wbk As Workbook

Set appXL = CreateObject("Excel.Application.9")
'appXL.Visible = True
Set wbk = appXL.Workbooks.Open(m_strPath & m_strFileName)
'wbk.RunAutoMacros xlAutoOpen
'ThisWorkbook.Close SaveChanges:=False
set appXL = Nothing

You just need to specify the path and file name...
 
Hi Jim,
I tried your suggestion, but got an ActiveX component can't create object
error. Any ideas?
 
Depends what version of excel you are running... In Excel click help and
About. You will see a version number like (9.0._____). The 9 is your version
number. change that in your code... Excel.Application.9
 

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

Back
Top