Access VBA - declared an Excel VBA reserved word and VBA/Access won't give it back!

U

ultar6

I'm working on an Access 2003 application that interacts with Excel
workbooks - so Microsoft Excel 11 Object Library is one of the
included references.

Unwittingly, I added the following declaration in a module:

Dim columnWidth as Double

Unfortunately, 'ColumnWidth' is the reserved word for the column width
property in Excel. Even so, VBA allowed me to do it (presumably
because VBA is in 'Access Mode' and isn't checking against other
Office applications for invalid use of reserved words).

It didn't take long for me to figure out what I had done, so I changed
the name of the variable to 'colWidth' and made sure to eradicate any
references to 'columnWidth'. There is absolutely NO remaining
reference in any of the code, not even any statements that attempt to
access the ColumnWidth property.

My problem - Access won't give me back the Excel 'ColumnWidth'
property. Wherever I type it, VBA changes it to 'columnWidth' with
the lower-case 'c' and treats it as a variable.

I've tried a few things to free up the property...

1. Removed Microsoft Excel 11 Object Library from references, closed
and then reopened the mdb, then added the library again.

2. Removed the module where I had done this, closed and then
reopenened the mdb, created a new module, gave it the same name as the
previous one, and pasted the function in (sans any reference to
'columnWidth'). I suppose I could try the same, but give the new
module a different name, but I have serious doubts this will work.

3. Ran the compact and repair utility - a definite long shot.

4. Of course, I also rebooted the machine to see if it might clear
out 'remembered' things like this.

I also went through the object browser. I found the 'colWidth'
variable, but the only reference I found to 'ColumnWidth' was the
range property in the Excel library.

Ironically, I declared this variable to hold the sum of the widths of
four columns so I could precisely place a chart on the edge of those
four columns.

Is there any kind of simple fix for this? My last-ditch will be to go
to a backup file and paste new code over old code in several places.

Thanks,

Ultar
 
A

Allen Browne

Declare a new variable:
Dim ColumnWidth As Double

Compile and save.

Then delete the variable again.
 

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