Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert Rows to Word table
Message
De
30/04/2003 06:28:00
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
30/04/2003 00:30:33
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Divers
Thread ID:
00783025
Message ID:
00783076
Vues:
16
This message has been marked as a message which has helped to the initial question of the thread.
>Hi all!!!
>
>Trying to learn some office automation. I have a word document with some tables....
>
>I want to add a new row to a table and put some text in....
>
>
>
>objwordapplication = CREATEOBJECT("Word.Application")
>
>objworddocument = objwordapplication.Documents.Open(templatedoc)
>
>*-- Find the bookmark
>oBookMark = objworddocument.Bookmarks["TestingTable"].Range
>*-- Select the entire table
>oTable = oBookMark.Tables[1].Range
>
>*-- How many rows are there?
>nRowCount = oTable.Rows.Count
>*-- Note: There are seven columns
>
>*-- Now, we will cycle first each row
>FOR lnOnRow = 1 TO nRowCount
> oItem = "NULL"
> oItem =IIF(TYPE("oBookMark.Tables[1].Cell[lnOnRow,1].Range")=="O", ;
>  oBookMark.Tables[1].Cell[lnOnRow,1].Range.Text, oItem)
> IF oItem = "insertrowafterhere"
>  llFlag = .T.
>  EXIT
> ENDIF
> IF llFlag
>  EXIT
> ENDIF
>NEXT
>
>
>So now lnOnRow = the 'source' row. I want to add one row. Could someone help me with some sort of syntax? I have the Microsoft Office Auotmation by Tamar/Della; but I am only finding things on adding new tables... not inserting a row in a table already on a document. PS: the search engine is down.
>
>TIA Heaps!!!
>
>Ric
#Define wdSeparateByCommas  2
#Define wdSeparateByDefaultListSeparator  3
#Define wdSeparateByParagraphs  0
#Define wdSeparateByTabs  1

#Define TABULATE Chr(9)
#Define NL Chr(13)+Chr(10)

lcTempFile = Sys(2015)+'.tmp'
Use employee
Copy To (lcTempFile) ;
  fields First_Name, Last_Name, Title ;
  type Delimited With Tab ;
  for Upper(Title) = 'SALES'
lnCols = 3
_Cliptext = Chrtran(Filetostr(lcTempFile),'"','')
Erase (lcTempFile)

oWordDocument=Createobject("word.application")	&& Create word object
With oWordDocument
  .documents.Add	&& New file
  With .ActiveDocument.Range
    .Paste      && Paste VFP data
    .ConvertToTable(wdSeparateByTabs,,lnCols) && Convert to table
    oTable = .Tables[1]
  Endwith
  *-- How many rows are there?
  nRowCount = oTable.Rows.Count
  nColCount = oTable.Columns.Count
  ? nRowCount, nColCount
  *-- Now, we will cycle first each row
  For Each oRow In oTable.Rows
    If oRow.Cells(1).Range.Text = "Nancy"
      If oRow.IsLast
        oTable.Rows.Add()
      Else
        oTable.Rows.Add(oTable.Rows(oRow.Index+1))
      Endif
      Exit
    Endif
  Endfor
  .Visible = .T.
Endwith
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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform