I have a program that is structured like this
sub Main
Dim objXL as excel.application
Dim objwkb as excel.workbook
dim objsht as excel.worksheet
Set Objxl=..
set objwkb=..
set objsht=...
Do stuff here
Call Sub Procedure
Call Sub Procedure
set objsht=nothing
set objwkb=nothing
set objxl=nothing
end Main
My Problem/Question is with the sub Procedures.
If I run the procedure with Excel closed everything works fine. If excel is open then it seems to get confused about which instance of excel to use. I tried to reference the work book name and pass it on to the sub procedures but it still doesn't recognize the correct instance. How do I ensure that the different parts of my program know the right instance to act against?
I'm fairly inexperienced at automation so any code samples or links are greatly appreciated! Thanks!
sub Main
Dim objXL as excel.application
Dim objwkb as excel.workbook
dim objsht as excel.worksheet
Set Objxl=..
set objwkb=..
set objsht=...
Do stuff here
Call Sub Procedure
Call Sub Procedure
set objsht=nothing
set objwkb=nothing
set objxl=nothing
end Main
My Problem/Question is with the sub Procedures.
If I run the procedure with Excel closed everything works fine. If excel is open then it seems to get confused about which instance of excel to use. I tried to reference the work book name and pass it on to the sub procedures but it still doesn't recognize the correct instance. How do I ensure that the different parts of my program know the right instance to act against?
I'm fairly inexperienced at automation so any code samples or links are greatly appreciated! Thanks!