I have the strangest problem. The other day, I wrote the code below on my laptop, and it worked fine. Now I am testing it on my desktop and it stops working.
First, here is my code
Dim oApp As Application Dim oWb As Workbook Set oApp = New Application oApp.Visible = True Set oWb = oApp.Workbooks.Open(Filename:="C:\myFile.xlsx", ReadOnly:=True) debug.print oWb.name 'returns "SOLVER.XLAM" ' "SOLVER.XLAM" is not "myFile.xlsx' debug.print oApp.Workbooks.Count 'returns 1 debug.print oApp.Workbooks(1).name 'returns "myFile.xlsx"
Now I know that the solver is an addition, and it loads into the new application when it is created ... but how does it execute this switch? I can still get to the desired file, but I do not want to risk it by coincidence that in my application object there is only 1 file (or the first file is the one I downloaded)
Additional Information
I am invoking the execution of this macro from an excel instance, and I want to open a separate excel instance and then open a specific workbook ( "C:\myFile.xlsx" ) inside that other instance.
The main problem I am facing is that when I open another instance and then add the book and set it in my oWb variable ... somehow, when I later call this variable oWb, it refers to something different from what i installed it.
'This is how it makes me feel: Dim x As Integer x = 5 Debug.Print x ' 12
vba excel-vba excel excel-2010
Mike PG
source share