Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
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 (3)
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