troubleshooting Question

Passing Bookmarks to a Microsoft Word Document from a Delphi application!!!

Avatar of trevsoft
trevsoft asked on
13 Comments1 Solution1010 ViewsLast Modified:
Hi Experts,

I am trying to set bookmarks in a work document from my delphi application, but i cant seem to get it to work properly.

I have this code that i am using currently:

procedure TOpenCaseFrm.Button2Click(Sender: TObject);
  S : Selection;
  R : Range;
  D : _Document;
  B : Bookmark;
  V : olevariant;

  // create new doc based on your template
  V := 'c:\test.doc';
  D := WordApplication1.Documents.Add(V, EmptyParam, EmptyParam, EmptyParam);

  // put your data in the bookmarks
  V := 'Test';
  R := D.Bookmarks.Item(V).Range;
  R.InsertBefore('my inserted data');

But as you can see it is actually inserting the text im passing before the actually bookmark. What i want to do is actually replace the bookmark with the text that i am passing.

Also if you can help how can i alter this procedure to print the document and close the document in background.

Your help would be greatly appreciated.

Thank you in advance.

Lukasz Zielinski
software developer
Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros