Do While Loop For xlApp Declaration

Herry Markowitz

Well-known member
Joined
Oct 22, 2015
Messages
46
Programming Experience
1-3
I am wating 10 seconds before xlApp declaration because C:\Book1.xlsx is a very big file and takes long time to open.
VB.NET:
Process.Start("C:\Book1.xlsx")
Threading.Thread.Sleep(10000)
Dim xlApp As Excel.Application = Nothing
xlApp = CType(GetObject(Nothing, "Excel.Application"), Excel.Application)

I want to replace above code like below code.
Below code need to be repaired.
VB.NET:
Process.Start("C:\Book1.xlsx")
Do While SOMETHING
   Application.DoEvents()
Loop
Dim xlApp As Excel.Application = Nothing
xlApp = CType(GetObject(Nothing, "Excel.Application"), Excel.Application)

 
Why not do it all with automation? Create an instance of Excel.Application and use its Workbooks.Open method.
 
Because I want to open excel file in Safe Mode.

VB.NET:
Process.Start("Excel.exe", "/safemode ""C:\Book1.xlsx""")
 
Back
Top