Word automation : addding picture

ashubhattashubhatt Member Posts: 8
Hi All,

I have been searching 'word automation' for adding picture in word document


--here is the sample code

Name DataType Subtype Length
wdApp Automation 'Microsoft Word 11.0 Object Library'.Application
wdDoc Automation 'Microsoft Word 11.0 Object Library'.Document
wdDocs Automation 'Microsoft Word 11.0 Object Library'.Documents
wdRange Automation 'Microsoft Word 11.0 Object Library'.Range


IF ISCLEAR(wdApp) THEN
CREATE(wdApp);
IF ISCLEAR(wdDoc) THEN
CREATE(wdDoc);

CLEAR(wdDoc);
CLEAR(wdRange);

IF ERASE('C:\21.DOC') THEN;

Filename1 := 'C:\2.DOt';
Filename2 := 'C:\21.DOC';
wdDoc := wdApp.Documents.Add(Filename1);
wdApp.ActiveDocument.Fields.Update;

CompanyInfo.GET;
WITH CONTACT DO BEGIN
FINDFIRST;

wdRange := wdApp.ActiveDocument.Fields.Item(1).Result;
wdRange.Text := "First Name";

wdRange := wdApp.ActiveDocument.Fields.Item(2).Result;
wdRange.Text := CONTACT.Surname;

End;

wdApp.Visible := TRUE;
wdApp.ActiveDocument.Fields.Unlink;
wdDoc.SaveAs(Filename2);


Now i need to add picture from item table in my word document. How can i do that??

Many Thanks

Comments

  • ashubhattashubhatt Member Posts: 8
    It falls over on line 1...Error comes up "Automation variable is not instantiated. "


    CompanyInfo.CALCFIELDS(Picture);
    CompanyInfo.Picture.EXPORT('C:\Pic.bmp',FALSE);

    Filename := 'C:\Pic.bmp'

    1. WordInlineShape := WordSelection.InlineShapes.AddPicture(theFileName);
    2. WordInlineShape.Height := 141.75;
    3. WordInlineShape.Width := 188.8;





    Name DataType Subtype Length
    WordSelection Automation 'Microsoft Word 12.0 Object Library'.Selection
    WordInlineShape Automation 'Microsoft Word 12.0 Object Library'.InlineShape
  • garakgarak Member Posts: 3,263
    WordSelection := WdApp.Selection; //Now you have the instance ;-)
    Do you make it right, it works too!
  • ashubhattashubhatt Member Posts: 8
    Thanks a lot...

    I need to show this picture in particular location in word document(say right bottom side). How can i achieve that??
  • ashubhattashubhatt Member Posts: 8
    Any ideas?

    Thanks
  • garakgarak Member Posts: 3,263
    Little Tip:
    Open Word -> Start Macro Recording -> Do this what Navision should do -> Stop macro recording -> View the VBA source.
    now you know which "Automations" you must use and how to do it .....

    Regards
    Do you make it right, it works too!
  • ashubhattashubhatt Member Posts: 8
    Yeah i tried macro but unfortunely it was'nt very helpful.

    I need to add picture to a bookmark in the word document. Any help??
Sign In or Register to comment.