Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Inserting Picture in Word Document
Message
From
24/08/2001 03:45:13
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
24/08/2001 02:06:06
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00548499
Message ID:
00548508
Views:
9
This message has been marked as the solution to the initial question of the thread.
>I need to insert picture to a Word document created directly from vfp.
>
>Also I would like to know if it is possible to obtain somehow,
>list of methods/properties that you can utilise from VFP using
>Word application object.
>Any help would be greatly appreciated.
>Thks+
Clear all
#Define wdWord9TableBehavior 1
#Define wdAutoFitWindow 2
#Define wdStory 6
#Define wdCollapseEnd 0
#Define wdCellAlignVerticalCenter 1
#Define CR chr(13)
lcPhotoPath = _samples+'\data\graphics\'

Use (_samples+'\data\employee')
oWord = createobject('Word.Application')
With oWord
  oDocument = .Documents.Add
  With oDocument.Application.Selection
    With oDocument.tables.add( .Range, 1, 7)
      .borders.InsideLineStyle = .F.
      .borders.OutsideLineStyle = .F.
      For ix=1 to 6
        **** Add captions *****
        .Cell(.Rows.Count,ix).Range.InsertAfter( field(ix) )
      Endfor
      .Cell(.Rows.Count,7).Range.InsertAfter( 'Photo' )
    Endwith
    .EndKey(wdStory)
  Endwith

  Scan
    With oDocument.Application.Selection
      With oDocument.tables.add( .Range, 1, 7)
        .borders.InsideLineStyle = .F.
        .borders.OutsideLineStyle = .F.
        For ix=1 to 6
          **** Add values to the different cells *****
          .Cell(.Rows.Count,ix).Range.InsertAfter( eval(field(ix)) )
        Endfor
        lcPhoto = lcPhotoPath+left(last_name,4)+left(first_name,4)+'.GIF'
        If file(lcPhoto) && Add photo if any
<B>          oDocument.InlineShapes.AddPicture(;
            lcPhoto, .T., .T.,.Cell(.Rows.Count,ix).Range) </B>
        Endif
        .Rows(.Rows.Count).Cells.VerticalAlignment = wdCellAlignVerticalCenter
      Endwith
      .EndKey(wdStory)
    Endwith
  Endscan
  .Visible = .t.
Endwith
Help filename depends on version. It's something like :
"F:\Program Files\Microsoft Office\Office\1033\Vbawrd9.chm"
Search for vbawrd*.chm or for older version vba_wrd*.hlp. However help file might not be installed at all if you didn't select VB help during installation. Add in that case.

One frequently used method is to record a macro in word and copy generated code to VFP. In VFP it needs some furnishing + macro code is not always the one that's better but helps. Parameters are named and has to made positional. For a more detailed info about these check < placehodlder for update >
Also in word constants like wd... are frequently used. A header file for those constants should be in download area.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform