ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Codename not set (https://www.excelbanter.com/excel-programming/434573-codename-not-set.html)

BigJimmer

Codename not set
 
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!

Peter T

Codename not set
 
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


"BigJimmer" wrote in message
...
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!




BigJimmer

Codename not set
 
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.


"Peter T" wrote:

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


"BigJimmer" wrote in message
...
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!






All times are GMT +1. The time now is 12:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com