AllExperts > FoxPro 
Search      
FoxPro
Volunteer
Answers to thousands of questions
 Home · More FoxPro Questions · Answer Library  · Encyclopedia ·
More FoxPro Answers
Question Library

Ask a question about FoxPro
Volunteer
Experts of the Month
Expert Login

Awards

About Us
Tell friends
Link to Us
Disclaimer

 
 
 
 
About Carla Fair-Wright
Expertise
I can answer most general questions regarding Visual FoxPro. I am also very good with WSH, WMI,and FSO scripting and most internet technologies. I like to answer questions. To me there is no such thing as a dumb question. Don't be afraid to ask me anything about FoxPro or Visual FoxPro. I will try to answer all questions as quickly as I can. It may take me a day or longer for a complex error or one that is hard to reproduce. Please include the version of FoxPro you are using.

Experience
My professional experience with computer programming started in my early twenties, I went back to college with thoughts of finishing an engineering degree and ended up in computer science.
I have used Oracle, SQL Server, Access, and FoxPro.

Experience in the area
I have been using the product for over 10 years. I am a MCP in Visual FoxPro (Desktop). I am ASQ Certified in Software Quality Engineering

Publications

Books
Chapter Author, Case Studies and Applications of Web Based Energy Information and Control Systems (Fairmont Press), June 2005

Chapter Author, Encyclopedia of Energy Engineering and Technology 1st Edition, (Francis Books) Spring 2006

Magazines
Component Developer Magazine
Maintenance Technology


Education/Credentials
BS - Computer Science
AS - Management Information Science
AS - Technical Management
AS - Electronic Systems Technology

Organizations

Member of Society of Women Engineers (SWE)
Member of American Society for Quality (ASQ)
 
   

You are here:  Experts > Computing/Technology > Databases > FoxPro > foxpro

FoxPro - foxpro


Expert: Carla Fair-Wright - 12/7/2006

Question

-------------------------------------------
The text above is a follow-up to ...

-----Question-----
I have a 43 .doc files. i would like to combine all files in one.doc file? can i use fox pro OLE to accomplish above
-----Answer-----
Ashisha,

I don't know what version of FoxPro you are using or what version of Word. You can use Foxpro to manipulate word documents. You'll have to use VBA which means FoxPro 3.0 or higher.

Dale F. Wiley has a great how-to on this
http://experts.about.com/q/Microsoft-Word-1058/combining-word-documents.htm

To use VBA start the Macro recorder.

Open the first document
Go to Insert, File
Navigate and select the file you want to combine and then click on Insert or Open.
Insert Files Number Two

Stop it when done.
View the macro and copy it to VFP.

This article will help you with the VBA conversion to VFP format

How to print a general field by using Word and Visual FoxPro 9.0
support.microsoft.com/kb/175173


Also this article might give you some ideas.

Creating a Table of Contents Spanning Multiple Documents
http://pubs.logicalexpressions.com/Pub0009/LPMArticle.asp?ID=148

Post in the forum if you have any problems.

Carla

Thanks Carla for quick response, I am using vfp 6.0
PARA lext, lbrow, lrpt
lTrans=.f.
nErrorCount=2

close table all

use macrotxt in 0 excl
sele macrotxt
zap
appe blank
repl l1 with "Sub CreateManual()"
use macroins in 0 excl
use macfiles in 0 excl
sele macfiles
zap
=messagebox("Select the Client-Specific Manual Pages List - TXT File",0+64,"Select TXT File")
appe from ? type sdf
store reccount() to nMaxRec
go top
do while ! eof()
 store recno() to nRecNo
 store '"'+allt(filename)+'", _' to cFileName
 sele macroins
 store allt(f1)+cFileName to cL1
 sele macrotxt
 appe blank
 repl l1 with cL1
 nCount=2
 sele macroins
 do while nCount<=12
   store "f"+allt(str(nCount)) to cFldName
   store &cFldName to cL1
   sele macrotxt
   if nRecNo=nMaxRec and nCount=10
     * do nothing
   else
     appe blank
     repl l1 with cL1
   endif
   nCount=nCount+1
   sele macroins
 enddo
 sele macfiles
 skip
enddo

sele macrotxt
appe blank
repl l1 with "End Sub"
copy to macrotxt.doc type sdf
! /N "C:\Program Files\Microsoft Office\Office11\WINWORD.EXE" K:\ChoiceOneLink\Manual\GroupGuideTemplate\macrotxt.doc
retu
above is my code.after this i go to word and create the macro word by coping the text. and i manually run the macro in in word and save the file with new name.

What i am donid in word i would like to do in vfp 6.0 using OlE. cloud you please help me ?

Thanks
Ashisha

Answer
Ashisha,

I believe this will work for you.

#DEFINE wdStory  6
#DEFINE No_ConfirmConversions .F.
#DEFINE No_Link .F.
#DEFINE No_Attachment .F.

loWordSession  = CREATEOBJECT('Word.Application')
loWordSession.Documents.Add
loWordSession.Visible = .T. && for testing

MESSAGEBOX("Select the Client-Specific Manual Pages List - TXT File",0+64,"Select TXT File")
lcFileName = GETFILE("txt")

* we ask for the 43 files to be added. I suggest you change this to a listbox
* using a listbox will allow to user select all the files at one time or
FOR liNumberOfDocuments = 1 TO 43

   WITH loWordSession

       .SELECTION.EndKey( wdStory ) && go to the end of the document
       .SELECTION.InsertFile(lcFileName,"", No_ConfirmConversions,No_Link,No_Attachment)
       
       MESSAGEBOX("Select the Client-Specific Manual Pages List - TXT File",0+64,"Select TXT File")
       lcFileName = GETFILE("txt")
       * no file was selected
       IF EMPTY( lcFileName )
           EXIT
       ENDIF
   ENDWITH

ENDFOR

* this is the combined document we save
lcFileName = "macrotxt.doc"

loWordSession.Visible = .T.

WITH loWordSession
   .ChangeFileOpenDirectory ( "K:\ChoiceOneLink\Manual\GroupGuideTemplate\" )
   .ActiveDocument.SAVEAS( lcFileName )
   .ActiveDocument.CLOSE()
ENDWITH



* we close word application
loWordSession.Quit

RETURN .T.

Good Luck,
Carla

Add to this Answer   Ask a Question


 
User Agreement | Privacy Policy | Kids' Privacy Policy | Help
Copyright  © 2008 About, Inc. AllExperts, AllExperts.com, and About.com are registered trademarks of About, Inc. All rights reserved.