View Full Version : ActiveDocument.BuiltInDocumentProperties Can only set ONCE.


Rob
03-02-2006, 05:45 PM
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;

Tony Jollans
03-02-2006, 06:54 PM
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>" <ryost --nospam-- <atdot> wrote in message
news:#27ZIEiPGHA.2300@TK2MSFTNGP15.phx.gbl...
> 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;
>
>

Rob
03-02-2006, 07:48 PM
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" <My Forename at My Surname dot com> wrote in message
news:u1l2$riPGHA.2296@TK2MSFTNGP10.phx.gbl...
> 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>" <ryost --nospam-- <atdot> wrote in message
> news:#27ZIEiPGHA.2300@TK2MSFTNGP15.phx.gbl...
>> 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;
>>
>>
>
>

Rob
03-02-2006, 07:52 PM
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);
> 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
03-03-2006, 12:43 PM
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.

--
Enjoy,
Tony


"Rob rent-right com>" <ryost --nospam-- <atdot> wrote in message
news:ew6gILjPGHA.3728@tk2msftngp13.phx.gbl...
> 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);
> > var
> > WordApp: OLEVariant;
> > begin
> > WordApp := CreateOleObject('Word.Application');
> > WordApp.Visible := False;
> > WordApp.Documents.Open(AWordDoc);
> > WordApp.Dialogs(86).Title := 'aaa';
> > WordApp.Save;
> > end;
>
>