Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Constants?
Message
De
17/09/1999 11:30:34
 
 
À
17/09/1999 06:57:34
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Divers
Thread ID:
00265502
Message ID:
00265948
Vues:
19
>>>>Is there an *.h file with all the constants that Word2000 uses. Also is there any good books on OLE Automation of particularly Word or the entire Office Suite. I am trying to create a Word *.Doc of a quotation, with data from VFP5.0, that can be attached to an E-mail and sent to the respective party. I am having a heck of a time trying to figure out how to move around in Word. I just want to do some basic formating, like set some tabs and change some font sizes. I just can't seem to figure out how to control the "Insert point" very well. Any guidance would be much appreciated
>>>>
>>>>Thanks in Advance.
>>>>
>>>>Jon
>>>
>>>
There is no mention about a difference in header files of w97 and w2000 in MSDN lib. w97 constants should be in files section. Help file is ...\Microsoft Office\Office\vbawrd8.hlp for w97.
>>>Understanding insertion point is a challenge :) But not only that if you go that way. It would be slow too (VBA).
>>>Instead create a template in word with formatting as you want. Instead of hardcoded text use fieldcodes. ie: insert fields :
>>>DOCVARIABLE "cFirst_name" \* MERGEFORMAT
>>>DOCVARIABLE "cLast_name" \* MERGEFORMAT
>>>and do any formatting in word. Then uncheck tools\Options\Field codes if checked.
>>>
>>>
>>>from VFP all you have to do is :
>>>
>>>
oWordDocument = createobject("Word.Application")
>>>with oWordDocument
>>>  .Documents.Add("c:\mypath\mysavedtemplate.doc") && New file with a template
>>>  with .Activedocument
>>>    _SetVar("cFirst_Name", myTable.First_name)
>>>    _SetVar("cLast_Name", myTable.Last_name)
>>>*...
>>>  endwith
>>>*...
>>> .Visible = .t. && Show word
>>>endwith
>>>
>>>
>>>FUNCTION _SetVar
>>>LPARAMETERS tcVarName, tcVarValue
>>> .Variables(tcVarName).value = iif(empty(tcVarValue)," ",tcVarValue)
This works pretty well for one record templates (or Parent table data).
>>>Cetin
>>

>>Thanks, I did find that *.h file in the files section. As for you code sample that would work pretty good for a parent table. But... I couldn't have anything that would be easy. Here is some code I was playing with originally, I was just creating an e-mail with the data, but when it gets to the other party it is "Wordwrapped" somewhere along the way, and is hard to make out.
>>
>>strSubject = "Quotation No.:  "+ALLTRIM(QTHD.QUOTENO)
>>
>>theApp = CreateObject("Outlook.Application")
>>theNameSpace = theApp.GetNameSpace("MAPI")
>>*theNameSpace.Logon(strProfile , strPassword)
>>theMailItem = theApp.CreateItem(0)
>>
>>*theMailItem.Recipients.Add( strRecipient )
>>theMailItem.Subject = strSubject
>>theMailItem.Body = test()
>>*theMailItem.Font.name = "Fixedsys"
>>theMailItem.display
>>theNameSpace.Logoff
>>
>>FUNCTION test
>>REQUERY("QUOTEVW")
>>m.Description = "Requested By:"+SPACE(2)+ALLTRIM(QTHD.REQUESTED_)+CHR(13)+;
>>	"Inquiry No.:"+SPACE(2)+ALLTRIM(QTHD.INQUIRY_NO)+CHR(13)+;
>>	"Inquiry Date:"+SPACE(2)+DTOC(QTHD.INQUIRY_DA)+CHR(13)+;
>>	"Date:"+SPACE(2)+DTOC(QTHD.DATE)+CHR(13)+;
>>	"Estimated Delivery:"+SPACE(2)+ALLTRIM(QTHD.ESTIMATED_)+CHR(13)+;
>>	"Terms:"+SPACE(2)+ALLTRIM(QTHD.TERMS)+CHR(13)+;
>>	"Salesman:"+SPACE(2)+ALLTRIM(QTHD.SALESMAN)+CHR(13)+CHR(13)+CHR(13)+;
>>	"Quantity"+SPACE(20)+"Description"+SPACE(20)+;
>>	"Umeas"+SPACE(10)+"Amount"+CHR(13)
>>	SELECT QUOTEVW
>>	FOR I = 1 TO RECCOUNT()
>>		GO RECORD I
>>		m.description = m.description+STR(QUOTEVW.QUANTITY)+;
>>			SPACE(2)+QUOTEVW.DESCRIPTION+SPACE(2)+QUOTEVW.UMEAS+;
>>			SPACE(2)+STR(QUOTEVW.AMOUNT,10,2)+CHR(13)
>>	ENDFOR
>>	m.Description = m.Description+CHR(13)+CHR(13)+CHR(13)
>>	m.Description = m.Description+QTHD.OTHER_INFO
>>	RETURN m.Description
>>ENDFUNC
>>
>>As you can see I can have a lot of items or just one. Got any Ideas?
>>
>>Jon
>>Non-MVP :)
>
>
You could attach a word file and "body" be that worddoc. Right ? It would free you of using fixedsys font too. Think this template in word :
>-Logo in header
>-"Thanks" message at footer
>
>A 2 columns table for "parent" part (up to including "salesman"). Left column would hold prewritten "Requested By:".."Salesman". No space(2) or chr(13). Column width serves for spaces and rows serve for chr(13). In right column you place fields :
>{DOCVARIABLE "REQUESTED_" \* MERGEFORMAT}
>...
>{DOCVARIABLE "SALESMAN" \* MERGEFORMAT}
>
>and format table in any font, style you want. _Setvar() would be used to fillin.
>Now below table place a bookmark for multirecords table. Just a bookmark no table no header.
>
SELECT QUOTEVW
>#define TABULATE chr(9)
>#define NL chr(13)
>m.description = "Quantity"+TABULATE+"Description"+TABULATE+;
>	"Umeas"+TABULATE+"Amount"+NL
>scan
>  m.description = m.description+padl(QUOTEVW.QUANTITY,len("Quantity")," ")+;
>	TABULATE+QUOTEVW.DESCRIPTION+TABULATE+QUOTEVW.UMEAS+;
>	TABULATE+STR(QUOTEVW.AMOUNT,10,2)
>  if !eof()
>    m.description = m.description+NL && New row
>  endif
>ENDscan
>_ClipText = m.description
>*You would go to bookmark in word and :
>
>WITH toWord.ActiveDocument
>  .Bookmarks(tcBookmarkName).Select
>  WITH .Application.Selection
>    .Collapse(wdCollapseEnd)	&& Go to end of bookmark
>    IF .Information(wdWithInTable) && If we're in a table
>      .MoveEnd(wdTable)
>      .Collapse(wdCollapseEnd)	&& Get out of table
>      .InsertParagraph()	&& Split table
>      .Collapse(wdCollapseEnd)	&& Clear selection
>    ENDIF
>    .Text = _cliptext		&& Paste clip data
>    lnWidth = tnPageColWidth / fcount()	&& Calculate evenly distributed width
>* Convert to table format Colorful 2
>    loTable = .ConvertToTable(wdSeparateByTabs,,lnHeaders,lnWidth, ;
>      wdTableFormatColorful2,,,,,,,.f.,,.f.)
>    .Find.Execute("~",,,,,,,,,chr(13),wdReplaceAll) && Restore memo para marks
>* Do not let row break if doesn't fit on same page
>    .Rows.AllowBreakAcrossPages = .f.	
>    .Collapse(wdCollapseEnd)
>  ENDWITH
>ENDWITH	
>= _FormatTable(toWord, loTable, tcBookmarkName, @taFieldAndCaptionNames)
Then insert few para marks + other info. That's it.
>Of course as you can read there are some variables and function used in code that you cannot find a reference. This was cut&pasted from a generic routine doing similar to what you do. In original routine instead of "m.description = m.description ..." style, opening a temporary lowlevel file, writing to it, reading from it to clipboard is used (IMHO faster). Also first line contains table headers (either derived froma datadictionary or DBC). FormatTable function as you might have guessed :) does formatting of created table to fit into its TextColumn (autoformat-autofit fail) and places hidden bookmarks to column headers (for some other purpose).
>
>In effect what you get it is a parent data + child table(s) placed in predefined bookmarks (or one after each other if bookmarks doesn't exist). Preparing data in VFP and doing as little work as possible in word awarded with speed. ie: One parent and 4 childs each having only few records of data is shown formatted and ready in word roughyly in 3-4 secs. (K6-2 333, 64Mb).
>
>Cetin

Gee Wiz Cetin, your good! I'm going to step through this info really slowly so hopefully I can pick it all up. I read through it, and it seems to make since but I'm sure I'll run into something along the way, so keep your eye's peeled for "Request for more info" messages. And Thanks a Bunch!!

Jon
Thanks
Jon
Non-MVP Non-MCP Non-MCSE

Visual FoxPro, What else is there?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform