Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This code does the trick for me, but as you can see I have to save the doc at once and the reopen it using ShellExecute. If not I get the 'RPC Server not available' error i mentioned earlyer.</p> <pre><code>procedure TfrmJobsearchAdverts.FileCreate; var TempName: OleVariant; FileDoc: OleVariant; FileFormat: OleVariant; Doc : WordDocument; WordTemplate: string; WordFile: string; BookName: OleVariant; begin SaveRecord; WordFile := Advert.CreateDocname(qryAdverts.FieldByName('fldadvert_date').AsDateTime); WordTemplate := JobsearchTemplate(Self); if (WordFile &lt;&gt; '') and (WordTemplate &lt;&gt; '') then begin Advert.SaveDocname(qryAdverts.FieldByName('fldadvert_guid').AsString, WordFile); if not Assigned(fWordApp) then InitializeWord; TempName := WordTemplate; FileDoc := WordFile; Doc := FWordApp.Documents.Add(TempName, EmptyParam, EmptyParam, EmptyParam); BookName := 'fldCompany'; if Doc.Bookmarks.Exists(BookName) then Doc.Bookmarks.Item(BookName).Range.Text := Company.Name; BookName := 'fldAddress1'; if Doc.Bookmarks.Exists(BookName) then Doc.Bookmarks.Item(BookName).Range.Text := Company.Address1; BookName := 'fldAddress2'; if Doc.Bookmarks.Exists(BookName) then Doc.Bookmarks.Item(BookName).Range.Text := Company.Address2; BookName := 'fldZip'; if Doc.Bookmarks.Exists(BookName) then Doc.Bookmarks.Item(BookName).Range.Text := Company.Zip; BookName := 'fldCity'; if Doc.Bookmarks.Exists(BookName) then Doc.Bookmarks.Item(BookName).Range.Text := Company.City; FileFormat := wdFormatDocument; Doc.SaveAs(FileDoc, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam, EmptyParam); FinalizeWord; Files.ExecuteAndWait(WordFile); end; end; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload