Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word automation question
Message
De
12/06/2003 13:26:02
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
12/06/2003 11:22:02
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00794194
Message ID:
00799459
Vues:
33
This message has been marked as a message which has helped to the initial question of the thread.
>Hi Cetin,
>
>As usual, I am astounded by the quality and quantity of your assistance. This helps a lot with what I need but I still need more (sorry !):
>
>1- The bookmark disappears in the merged document. Why ? I placed it in the original doc. In the merged doc (where I need to add the table), it is gone.
>How can I insert it at a given point. FIND syntax would help.
>
>2- Syntax for fixing 'case'
>3- Syntax for readjusting column widths (fit-to-content or hard-coded values)
>4- Syntax for printing to a specific printer driver (PDF, RightFax, etc...)
>
>Again, thanks for your help.
>
>Henry

Henry,
A quick one. Might not directly answer what you want.
Bookmarks would be gone because a bookmark name needs to be unique. Merging what would be the names per merge ? But I'm not sure there might be a way.

Find looks like :
lcFindValue = "Visual Studio"
oWord=createobject('Word.Application')
with oWord
 .Documents.Open(GetFile('DOC'))
 loRange = .ActiveDocument.Content
 loRange.Select
 llRetVal = .Selection.Find.Execute(lcFindValue)
 .Visible = .t.
 .Activate
 if llRetVal
   loSelection = oWord.Selection  && return an object reference
 else
   return .null.
 endif
endwith
?loSelection.text
3- Is easy and yet very complex. I can only give partial code from a live app for now :
#Define nTwipsPerInch  1440

lnPixelsPerInch = _GetPixelsPerInch(0) && 0 Horizontal

* 1 Twip = 1/20 point, 567 twips 1 cm, 1 mm column gap

lnSizeInPixels = txtwidth(lcSampleText, lcFont, lnFontSize) * ;
  fontmetric(6, lcFont, lnFontSize)
*...
loTable.Columns(ix).Width = ;
 ( lnSizeInPixels  / lnPixelsPerInch * nTwipsPerInch + (567 * 0.1) ) / 20

Function _GetPixelsPerInch
Lparameters lnDirection	&& 0 horizontal otherwise vertical
If pcount() = 0
	lnDirection = 0
Endif

* Declarations done in main.prg
*!*	Declare INTEGER ReleaseDC IN Win32Api;
*!*		INTEGER nwnd, INTEGER hdc
*!*	Declare INTEGER GetDeviceCaps IN Win32API;
*!*		INTEGER hdc, INTEGER nIndex
*!*	Declare INTEGER GetWindowDC IN Win32API;
*!*		INTEGER hWnd

#Define WU_LOGPIXELSX  88
#Define WU_LOGPIXELSY 90
lnDC = GetWindowDC(0)
lnPixelsPerInch = GetDeviceCaps(lnDC, ;
 iif( lnDirection = 0, WU_LOGPIXELSX, WU_LOGPIXELSY ) )
lnDC = ReleaseDC(0, lnDC)
Return lnPixelsPerInch
For printer check PageSetup object.

PS: Instead of bookmarks you could place dummy tables 1 row/1 col as placeholders. Later access with syntax like Sections(recno).Tables(nIndex)

Also there is a word field Database but don't know the details. Never tested.
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