Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
General Field Save as File (Revisited)
Message
From
10/07/2003 04:47:12
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
09/07/2003 16:17:26
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00808677
Message ID:
00808767
Views:
14
>OK, I lied. Thread 808042, Message 808093 did not solve my problem after all. The following code does not actually save any files to disk and does not produce any errors either:
>
>IF !USED("lettype")
> USE lettype
>ELSE
> SELECT lettype
>ENDIF
>SCAN
> WAIT WINDOW "Refreshing " + ALLTRIM(lettype.letname) + "..." NOWAIT
> ThisForm.oWord.Refresh()
> ThisForm.oWord.Object.SaveAs(lettype.letname)
>ENDSCAN
>
>The .Object... does not show up in Intellisense, yet it does not produce any error or warning at runtime. What am I missing?
>
>I would prefer avoiding the solution of creating a separate Word instance and cutting / pasting the General Field contents into it because that will not guarantee the other document properties will be applied (i.e. page orientation, etc.). Also, I would prefer not to use the solution that incororates low-level file handling with a 599 offset because it appears that will not always be valid. In addition, using binary memo fields or storing the files completely outside a table are pretty much out of the question at this point because of time and design constraints.
>
>Why on Earth would MS create a General Field that will store files without providing a reasonable way of getting them back out? There must be an easier way to get these Word documents back out of the General Field. Anyone?

Scott,
This worked well for me :
oForm = Createobject('myForm')
oForm.Show()
Read Events

Define Class myForm As Form
  Height=400
  Width=800
  Add Object myWord As OleBoundControl ;
    With ControlSource = "myWordDocs.doc", Name='myWord', ;
    width=800, Height= 300

  Add Object SaveButton As CommandButton ;
    With Name='SaveButton', Top=350, Caption = 'Save'

  Procedure Load
    Use myWordDocs
  Endproc

  Procedure QueryUnload
    Clear Events
  Endproc

  Procedure SaveButton.Click
  	LOCAL oWord
    With Thisform
      Select myWordDocs
      Scan
        .Refresh()
        .myWord.Object.SaveAs(Sys(5)+Curdir()+;
             'DOCUMENT_'+Transform(Recno('myWordDocs'))+'.doc')
      Endscan
    Endwith
  Endproc
Enddefine
However this would leave a word session open for each scanned doc and I don't have an idea how would you close them.

I prefer and suggest you to use the one in 'not solving' thread. There browse other messages for 'winword leaving open sessions' solution and use that one. That approach loses page setup and similar if you use that way, right. But you could query those properties from 'general' field one (.myWord.Object) and apply to new copy.

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
Reply
Map
View

Click here to load this message in the networking platform