Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Export to WORD
Message
From
15/04/2002 10:21:48
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
15/04/2002 09:45:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00644987
Message ID:
00645008
Views:
11
>Hi all,
>
>Please guide how to export *.dbf to WORD on top using only
>copy to command ? means to automate completely the process.
>
>TIA
>PP

Copy to is longer IMHO.
#Define wdTableFormatColorful1  8
#Define wdTableFormatColorful2  9
#Define wdTableFormatColorful3  10
#Define wdTableFormatColumns1  11
#Define wdTableFormatColumns2  12
#Define wdTableFormatColumns3  13
#Define wdTableFormatColumns4  14
#Define wdTableFormatColumns5  15
#Define wdTableFormatContemporary  35
lcSQL = "select last_name, first_name, title, country from employee"
* Prepare DSN string
cDSN = [DSN=Visual FoxPro Database;SourceDB=]+_samples+[\data\testdata.dbc]+;
  [;SourceType=DBC;Exclusive=No;BackgroundFetch=Yes;Collate=Machine;]+;
  [Null=Yes;Deleted=Yes;]
*** set the LOCALEID to English
nlLocaleId=sys(3004)		&& Save local id
=sys(3006,1033)			&& We will be sending instructions in English
Wait window nowait "Creating Word Document..."     && Inform user
oWordDocument=createobject("word.application")	&& Create word object
With oWordDocument
  .Documents.Add
  With .ActiveDocument
    .Range.InsertDatabase(,,,cDSN,lcSQL)
    * Set the heading row fieldnames to a suitable format
    With .tables(1)
      _SetCellHeading(1,"Employee's Last Name")
      _SetCellHeading(2,"Employee's First Name")
      _SetCellHeading(3,"Employee's Title")
      _SetCellHeading(4,"Country")
      .Autoformat(wdTableFormatColorful1)
    Endwith
  Endwith
  Wait clear
  .visible = .t.
Endwith

**** Set the LocaleId to the previous value
=sys(3006,val(nlLocaleId))
Wait clear	&& Clear wait windows if any

* Change Row1, tnColumn text to tcValue
Function _SetCellHeading
  Lparameters tnColumn, tcValue
  With .Cell(1,tnColumn)
    .Range.Delete
    .Range.InsertAfter(tcValue)
  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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform