Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automating Word
Message
From
01/04/2000 09:30:10
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/03/2000 15:39:34
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Miscellaneous
Thread ID:
00351619
Message ID:
00353881
Views:
14
>I have a table that has a general field called Docs for example. In this general field I have embedded a Word 97 document. Currently I have learned how to print a document using the following code:
>
>range = "999"
>from = "1"
>to = "999"
>oword = CreateObject("Word.Application")
>WITH oword
> .Documents.Open("C:\My Documents\MyDoc.doc")
> .ActiveDocument.PrintOut(0,0,range,"",from,to)
> .Quit
>ENDWITH
>
>My question is: How do I replace "C:\My Documents\MyDoc.doc" with the contents of my general field? I basically don't know how to reference the Word document that resides in my general field in order to print it.
>
>Thanks A Lot!
>Tom Welch


Tom,
I also think saving to memo binary or just keeping path&name is better. Anyway it might be to much asking you to convert to that style already in general field. So here's "one" way of doing it from general field (OleBoundControls are hosted by their applications themselves - word.application, that's instead of oWord = createobject("word.application") you use directly myForm.myContainer.myOleboundcontrol ) :
Create cursor wtest (wf g)
Append blank
Append general wf from (getfile("DOC"))
lcSampleTable = _samples+"\data\employee"
oform = createobject("form")
With oform
  .addobject("olbW","Oleboundcontrol")
  .height = 420
  .width = 620
  With .olbW
    .top = 10
    .left = 10
    .height = 400
    .width = 600
    .controlsource = "wtest.wf"    	&& "Embedded" word doc
    #Define wdSeparateByTabs  1
    #Define wdTableFormatColorful1 8
    #Define wdSaveChanges  -1
    #Define wdCollapseEnd  0
    Select first_name, last_name ;
      from (lcSampleTable) ;
      into cursor myCursor
    Application.datatoclip("myCursor",_tally, 3)
    With .object
      .Content.select
      With .Application.Selection
        .Collapse(wdCollapseEnd) && Go to end of selection - remove selection
        .Text = "Hello from VFP."+chr(13)
        .Collapse(wdCollapseEnd)
        .Text = _cliptext
        .ConvertToTable(wdSeparateByTabs,,,, ;
          wdTableFormatColorful1,,,,,,,.f.,,.f.)	&& Convert to table format Colorful 1
      Endwith
      .saveas("c:\temp\savedfromgen.doc")  && saved to disk
      .close(wdSaveChanges)
    Endwith
    *	.visible = .t.
  Endwith
  *.Show								&& If you want to display the form
Endwith
*READ EVENTS	&& Start event processing - not needed if just process the word object in background and quit
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