Codename not set

B

BigJimmer

I have an add-in that runs code when any workbook is opened.

During these steps the CodeName of some worksheets in the workbook being
opened are referenced.

If Excel is running before a particular file is opened, and then the
workbook is opened, the code works fine.

However, if Excel is not running, and I double click on the Excel file to
open it, when I get to the step where I reference the CodeName it returns an
empty string.

In trying to debug this I added the following to be able to break into the
code...

x = ws.CodeName
err.raise

When I debug at this breakpoint, I see x = "" and yet when I hover over
ws.CodeName I see the actual worksheet CodeName (it is no longer "").

Does anyone know why this would be happening?

Thanks!
 
P

Peter T

The scenario you describe usually occurs when a new sheet has been added
(manually or programmatically)*and* the VBE is not open. Can you relate that
to what's happening for you. Presumably the VBE is not open before starting
Excel but are you adding a new sheet in the newly opened workbook.

Regards,
Peter T
 
B

BigJimmer

VBE is closed, but no new sheets are being added to the workbook.

I'm looping through each sheet in the workbook being opened, and if certain
information is found within the formulas on a sheet, then I need to perform
other steps. This is when I try to access the worksheet code name of the
sheet that is current in the loop and get the problem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top