My experience is that being explicit is the best way of doing automation. This would mean declarate and instantiate objects at least down to sheet level, if sheet level is needed.
And never ever rely on any of the .Activethingies, which is impicit referencing, and might not refer to what you hoped it referred to.
[tt]Set XLAPP = CreateObject("Excel.Application")
'With XLAPP
dim wr as object 'excel.workbook
set wr = xlapp.Workbooks.Open FileName:= _
strFilePath
If strNewPath <> "" Then
wr.SaveAs FileName:=strNewPath _
, FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'Bunch of code that manipulates file makes a selection...
' Now - I don't remember which is the parent object of
' the .selection object and the .cells object
' but do declare and instantiate objects, and refer
' through the parent object in stead of the implicit
' referencing you're doing
' you'll most likely also find extra instances of Excel
' in memory after such errors
' now - the below is just OTOH, as I'm not in a position
' to test at the moment, you need to check/find what
' is the parent object of the .selection object and
' the .cells object are, and use them
Thanks Roy, that was my code hunch but it is good to see some experince behind the thought before taking the time... Hopefully I will get to it today. Unfortunately this is not the only anomalous thing I am looking at <sigh>.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.