• 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?  
0
DCRAPACCESS
Asked:
DCRAPACCESS
  • 3
1 Solution
 
Stephan_SchrandtCommented:
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
0
 
Stephan_SchrandtCommented:
Use:

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

to open it in read write mode
0
 
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?
0
 
Stephan_SchrandtCommented:
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.
0

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