B
BigJimmer
I use the worksheet codename extensively throughout my add-ins. However at
times I get errors because the codemame is not initialized at the point in
the code where it is being referenced.
For example, if I add something like this to my code....
sub Test (ws as Worksheet)
dim str as string
str = ws.CodeName
if str = "" then
debug.print "Missing Codename"
else
debug.print "CodeName = " & ws.Codename
end sub
I sometimes will get "Missing Codename", and other times (for the same
worksheet), it returns the code name. If I try stepping through the code, it
will always return a value for CodeName.
I have narrowed the occurrence of the problem down to being when the
worksheet uses the default code name (Sheet#) and the code is run either
during the workbook open event, or is run using a worksheet that was just
added to the workbook.
Any ideas on how to resolve this problem?
This happens in both Exccel 2000 and 2003.
times I get errors because the codemame is not initialized at the point in
the code where it is being referenced.
For example, if I add something like this to my code....
sub Test (ws as Worksheet)
dim str as string
str = ws.CodeName
if str = "" then
debug.print "Missing Codename"
else
debug.print "CodeName = " & ws.Codename
end sub
I sometimes will get "Missing Codename", and other times (for the same
worksheet), it returns the code name. If I try stepping through the code, it
will always return a value for CodeName.
I have narrowed the occurrence of the problem down to being when the
worksheet uses the default code name (Sheet#) and the code is run either
during the workbook open event, or is run using a worksheet that was just
added to the workbook.
Any ideas on how to resolve this problem?
This happens in both Exccel 2000 and 2003.