Word Title Property Dilema

S

shane

Hi.

Previously posted to Word_VBA @ yahoo and Word_PC.

Word 2002 on Win XP. All up-to-date.

I have a template that runs a Document.New event. The main part of my
problem starts with:

ActiveDocument.BuiltInDocumentProperties("Title") = vDocType + vDate

I've also tried:

ActiveDocument.BuiltInDocumentProperties(wdPropertyTitle) = vDocType +
vDate

Where vDocType and vDate are declared variables and have values
assigned.

When a new document is created from my template the Title in the
Properties Summary tab has my document type and the date as expected
However the Contents tab in Properties shows either the first lot of
text in the document or the pre-populated Title from the template if I
have set it.

When a Save As is run my Title isn't the default filename. The text
from the Contents tab is being used. I have tried to overwrite the
Contents tab info by duplicating the above BuiltInDocumentProperites
task and putting it in an on click event from a userform but this
doesn't change the Contents tab info and therefore not picked up
during a Save As.

What I'm tring to do is have my text in the Title property so that
when a Save As is run my info is the default file name. I "can't" use
a Save As (not that I know of) because this is handled by a third
party password protected add-in. This would mean my users having to
do two Save As tasks. Not ideal. The other option is to break the
password of the add-in. Again, not ideal.

I'm hoping someone can suggest a way for me to set my default filename
so that when the add-in runs it picks up my Title property properly.

Thanks in advance.

Shane
 
J

Jezebel

The problem is a bug in how Word handles the Title property. The work-around
is to execute the SummaryInfo dialog --

With Dialogs(wdDialogFileSummaryInfo)
.Title = vDocType & vDate
.Execute
End With

BTW, it's unwise to use "+" to concatenate strings.
 
S

Shane

Tks Jezebel. That worked.
BTW, it's unwise to use "+" to concatenate strings.

Is it to make the distinction between concatention of strings with
mathematical functions or is there another reason?

Cheers
Shane
 
J

Jezebel

Is it to make the distinction between concatention of strings with
mathematical functions or is there another reason?

The problem is that if any of the variables can be interpreted as a number,
VBA may choose to add them instead. This is particularly an issue if any of
them is a variant, in which case VBA feels free to convert data types. Play
around with expressions like

"1" + 2
or
Now + "3"

Even if you don't use variants yourself, quite a few VBA functions do; so it
is *very* hard to predict what's going to happen.

If you always use '&' the problem simply isn't there.
 
S

Shane

I see your point. Thanks for that.

Cheers


The problem is that if any of the variables can be interpreted as a number,
VBA may choose to add them instead. This is particularly an issue if any of
them is a variant, in which case VBA feels free to convert data types. Play
around with expressions like

"1" + 2
or
Now + "3"

Even if you don't use variants yourself, quite a few VBA functions do; so it
is *very* hard to predict what's going to happen.

If you always use '&' the problem simply isn't there.
 

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