Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using Word
Message
De
28/11/2005 13:40:42
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
28/11/2005 12:45:53
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Versions des environnements
Visual FoxPro:
VFP 6
OS:
Windows XP
Divers
Thread ID:
01072520
Message ID:
01072543
Vues:
21
>I am trying to work with a Word 2000 document that has 17 blank pages. I have downloaded a help file of Word Examples using VB, but I am not able to get them to work in VFP6. Essentially, I want to add a picture on each page and save the document with a new name. Any help with VFP examples would be great.
Clear All
#Define wdPageBreak	7
#Define wdGoToNext	2
#Define wdGoToPage	1

* Create test document with 17 blank pages
lcDoc = Forcepath(Sys(2015) + '.doc',Sys(2023))
oWord = Createobject('Word.Application')
With oWord
  .Documents.Add
  For ix=1 To 16
    .Selection.InsertBreak(wdPageBreak)
  Endfor
  .ActiveDocument.SaveAs(m.lcDoc)
  .Quit
Endwith
* Create test document with 17 blank pages


lcPhotoPath = _samples+'\data\graphics\'
Use (_samples+'\data\employee')

oWord = Createobject('Word.Application')
With oWord
  .Visible = .T.
  .Documents.Open(m.lcDoc) && Open existing
  lnAdded = 0
  Scan While m.lnAdded < 17 And !Eof()
    lcPhoto = m.lcPhotoPath+Left(last_name,4)+Left(first_name,4)+'.GIF'
    If File(m.lcPhoto)
      .ActiveDocument.InlineShapes.AddPicture( m.lcPhoto, .F., .T.,.Selection.Range)
      lnAdded = m.lnAdded + 1
    Endif
    .Selection.GotoNext(wdGoToPage)
  Endscan
Endwith
PS: Not erasing temp doc. Update _samples... line to point to samples folder.
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform