Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Opening word document embedded in a general field
Message
 
 
To
06/01/2003 12:50:22
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00737898
Message ID:
00739447
Views:
20
Many thanks to Cetin and Nancy for their help. This is Cetin's method with insignificant modifications to allow proper formatting of the word doc. The Doverb also worked good.

*!* I used the two methods. The second method used doverb

*!* Method 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
*!* Assuming you have createed a table/cursor named 'myWordDocs'
*!* with a general field named 'doc'

Clear All o*

Public startdir && start directory
startdir=Sys(5)+Sys(2003)+'\' && or sys(5)+curdir()

If Used("myWordDocs")
Select myWordDocs
Use
Endif

Set Safety Off
Create Cursor myWordDocs (Doc g)
Append Blank
*!* Add a word doc
nameoffile=""
nameoffile=(Getfile('doc'))

Set Defa To &startdir && return to start folder/directory

If Len(Alltrim(nameoffile))<>0
WAIT WINDOW 'Please wait..' nowait
Append General Doc From (nameoffile) &&(Getfile('doc')) && link can be used

#Define wdWindowStateNormal 0
#Define newline Chr(13)
#Define wdstory 6
Local oForm
oForm = Createobject('myForm')
Endif
Define Class myForm As Form
Add Object myWord As OleBoundControl ;
With ControlSource = "myWordDocs.doc", Name='myWord', ;
width=800
Procedure Load
Select myWordDocs
Endproc

Procedure Init
Local oWord
oWord = Createobject("Word.Application")
oWord.Documents.Add
With This
Select myWordDocs
Scan
.Refresh()
.myWord.Object.Content.Copy
oWord.ActiveDocument.Content.Paste
oWord.ActiveDocument.PageSetup.Papersize = 2
Endscan
Endwith
oWord.Visible=.T.
****************************************
*!* oWord.run("Macro3") && run basic macro or:
****************************************
With oWord && in most cases finds and updates word doc table of contents if any
.Selection.HomeKey (wdstory)
.ActiveWindow.View.ShowFieldCodes = .T.
.Selection.Find.ClearFormatting
With oWord.Selection.Find
.Text = "toc"
.Replacement.Text = ""
.Forward = .T.
.Wrap = 1
.Format = .F.
.MatchCase = .F.
.MatchWholeWord = .F.
.MatchWildcards = .F.
.MatchSoundsLike = .F.
.MatchAllWordForms = .F.
Endwith
.Selection.Find.Execute
.Selection.Fields.Update
.ActiveWindow.View.ShowFieldCodes = .F.

Endwith
****************************************8
oWord.ActiveDocument.SaveAs(Sys(5)+Curdir()+;
'DOCUMENTS_'+Transform(Recno('myWordDocs'))+'.doc')
_Cliptext =""
*!* oWord.Quit
Endproc

Enddefine
*********************************************88
*********************************************8
Previous
Reply
Map
View

Click here to load this message in the networking platform