How to open an excel file from VBA

How to open an excel file from VBA

jake_egley
Advocate Advocate
839 Views
3 Replies
Message 1 of 4

How to open an excel file from VBA

jake_egley
Advocate
Advocate

I have a macro that fills out an excel spreadsheet and saves it. Now I want it to open the spreadsheet for the user to see when the macro has finished. As opposed to the user going to file explorer to open it after running the macro. I tried several workbooks.open variations and none are working for me. Thank you

Jake Egley
Inventor 2022
0 Likes
Accepted solutions (1)
840 Views
3 Replies
Replies (3)
Message 2 of 4

marcin_otręba
Advisor
Advisor
Accepted solution

if you are using excel to fill date then for sure you open it propably invisible ? something like:

 

Dim XL As Object
Dim xlWS As Object
Set XL = CreateObject("Excel.Application")
XL.Visible = False

 

then after saving it you can use :

 

XL.Visible = True

 

if not then you can use :

Dim XL As Object
Dim xlWS As Object
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Open (bomname)

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 4

jake_egley
Advocate
Advocate

Works Great. Thank you. Do you know how to open a file explorer window and make it visible? So when the ilogic is done there is a file explorer window open at the location where my excel file is saved.

Jake Egley
Inventor 2022
0 Likes
Message 4 of 4

A.Acheson
Mentor
Mentor

Hi @jake_egley 

Try this from this help page on stackoverflow here

Dim Foldername As String
Foldername = "\\server\Instructions\"

Shell "C:\WINDOWS\explorer.exe """ & Foldername & "", vbNormalFocus

 

If this solved a problem, please click (accept) as solution.‌‌‌‌
Or if this helped you, please, click (like)‌‌
Regards
Alan