• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 883
  • Last Modified:

vba xlsm open hidden

Hi Experts

I have a xlsm file with some code inside. I would like to open the xlsm file. Then the code inside the xlsm file is running, and the xlsm file will save and close it self. As it is now i'm opening the file like this:
Application.FollowHyperlink "C:\UK\PP_BF.xlsm"
But the I get a message box the ask me if i want to open the file. I don't want this box to appear, and if possible the excel file should be open hidden.

Can someone help me with this?  
  • 3
1 Solution
With following the hyperlink you give the control to system. Try this (you can change xlApp.Visible to false later) , but please note the application will not exit, so if the excel sheet does not quit the application then the excel process stays in memory.

Dim xlBook  As Object
Dim xlApp   As Object

Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Open( "C:\UK\PP_BF.xlsm")
xlApp.Visible = true
Set xlApp = Nothing
Set xlBook = Nothing

Set xlBook = xlApp.Workbooks.Open( "C:\UK\PP_BF.xlsm",,False)

to open it in read write mode
DCRAPACCESSAuthor Commented:
just to be sure, the code inside the excel file, will it run and be done before the code continues and set the xlBook and xlApp to nothing?
No, it is asynchronous. Therefore be sure to do an application.quit in your excel macro when it exits. The lines Set xlApp = Nothing and Set xlBook = Nothing do not affect your macro, but only release the memory in vba.

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now