ActiveDocument.BuiltInDocumentProperties Can only set ONCE.

R

Rob

I found the code that updates the BuiltInDocumentProperties; and it works
perfectly...the first time.

But if I change 'Your title...' to something else and run it again, it still
has 'Your Title...' in the Title

does anyone know what I am doing wrong that this only works one time per
document.

I am using D6 and Word2003.

Thanks in advance,
Rob
++++++++++++++++
var
WordApp: OLEVariant;
SaveChanges: OleVariant;
begin
try
WordApp := CreateOleObject('Word.Application');
except
Exit;
end;
try
WordApp.Visible := False;
WordApp.Documents.Open(AWordDoc);
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertyTitle].Value
:= 'Your Title...';
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertySubject].Value
:= 'Your Subject...';
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertyKeywords].Value
:= 'Your Keywords...';
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertyComments].Value
:= 'Your Comments...';
finally
SaveChanges := wdSaveChanges;
WordApp.Quit(SaveChanges, EmptyParam, EmptyParam);
end;
 
T

Tony Jollans

Try ...

With Dialogs(wdDialogFileSummaryInfo)
.Title = "Document Properties are Fun"
.Execute
End With

Just don't ask me to explain :)
 
R

Rob

Thanks,
I tried:
procedure TForm1.Button4Click(Sender: TObject);
var
WordApp: OLEVariant;
begin
WordApp := CreateOleObject('Word.Application');
WordApp.Visible := False;
WordApp.Documents.Open(AWordDoc);
WordApp.Dialogs(86).Title := 'aaa';
WordApp.Save;
end;
Tony Jollans said:
Try ...

With Dialogs(wdDialogFileSummaryInfo)
.Title = "Document Properties are Fun"
.Execute
End With

Just don't ask me to explain :)

--
Enjoy,
Tony


Rob rent-right com> said:
I found the code that updates the BuiltInDocumentProperties; and it works
perfectly...the first time.

But if I change 'Your title...' to something else and run it again, it still
has 'Your Title...' in the Title

does anyone know what I am doing wrong that this only works one time per
document.

I am using D6 and Word2003.

Thanks in advance,
Rob
++++++++++++++++
var
WordApp: OLEVariant;
SaveChanges: OleVariant;
begin
try
WordApp := CreateOleObject('Word.Application');
except
Exit;
end;
try
WordApp.Visible := False;
WordApp.Documents.Open(AWordDoc);
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertyTitle].Value
:= 'Your Title...';
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertySubject].Value
:= 'Your Subject...';
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertyKeywords].Value
:= 'Your Keywords...';
WordApp.ActiveDocument.BuiltInDocumentProperties[wdPropertyComments].Value
:= 'Your Comments...';
finally
SaveChanges := wdSaveChanges;
WordApp.Quit(SaveChanges, EmptyParam, EmptyParam);
end;
 
R

Rob

Sorry I hit send a little prematurely,
I did try the snippet below, but I received 'Dialogs not a method' as an
error message.

"> procedure TForm1.Button4Click(Sender: TObject);
 
T

Tony Jollans

Sorry, Rob, I don't know what may cause that - could it be something to do
with the environment you're running Word in which may not allow Word
dialogs - just a guess, I'm afraid.
 
Top