Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
lfalmoguera
Creator
Creator

Vba Macro. Open excel only if it is closed

Hello all, 

thanks a lot in advance for the huge support of the community.

I am struggling with something that has to be pretty easy.

I have a vba macro that opens an excel file:

sub openExcel
    set XLApp = CreateObject("Excel.Application")
    set XLDOC = XLApp.Workbooks.Open("C:\Users\Luis\mydocument.xlsx")
     XLApp.Visible = True
end sub

Is there anyway to ONLY open mydocument.xlsx if it is closed, and do nothing if is already openened?

I have search for almost 5h within stackoverflows and QVCommunity but none of the answers seem to work.

Thanks in advance.

Labels (1)
1 Reply
marcus_sommer

What's the problem if the file is already opened respectively what do you want to do with the file?

- Marcus