VBA built-in object names auto-switching to lowercase--why?

B

Benjamino5

I'm working on code that frequently uses the Fields collection, but when I
type something into the VBA editor, the word "Fields" is automatically
switched to lowercase, like this:

ActiveDocument.fields.Update

Normally, it would automatically be made uppercase, so I'm assuming the VBA
editor is indicating some sort of problem by making it lowercase--but what?
Why is this happening?
 
J

Jezebel

This will happen if you have used 'fields' (all lower case) as a name
defined somewhere in your own code (anywhere in the project), as a variable
or function. It doesn't indicate a problem; it's just a quirk of the way VBA
maintains its lists of names. Try this --

Sub MySub()

Dim fIeLdS As String
Dim uPdAtE As String

activedocument.fields.update

End sub
 
B

Benjamino5

Interesting.

The weird thing is that when I delete ALL the code from the template--every
single bit--"fields" is STILL in lowercase.

I suppose it doesn't really matter, but it seems odd.

Thanks for the info!
 
T

Tony Jollans

Yes it is a little odd. I don't know why (or how) but VBA remembers the
capitalisation most recently used. You can change it back easily by, using
Jezebel's code as an example, ..

Sub MySub()

Dim Fields As String
Dim Update As String

activedocument.fields.update

End sub

Just type it in and then delete it - there should be no need to run it.
 

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