I can't see in your code where the variable FajlDOC comes from, but make certain it contains the full drive and path. Word won't know anything about the VFP search path.
Alan
>I use this code for merging into word from vfp. Everithing works fine in win98 and office 97. But on win XP and office XP something goes wrong???
>
>
>
>Local oWord, lcFileName, lcConnectionString, oFormLetter
>
>lcFilename = ADDBS(This.cDataPath) + This.cDataSource + ".CWH"
>
>IF EMPTY(this.cDocFolder)
> PathDoc = ""
>ELSE
> PathDoc = ADDBS(ALLTRIM(this.cDocFolder))
>ENDIF
>
>FileDOC = PathDOC + ALLTRIM(this.cFileForMerge)
>
>IF !DIRECTORY(This.cDataPath) Then
> MESSAGEBOX("Nonexistance of table : " + This.cDatapath, 0, "Error")
>
> RETURN .F.
>ENDIF
>
>IF !FILE(ADDBS(This.cDatapath) + This.cDataSource + ".DBF") THEN
> MESSAGEBOX("Table " + ADDBS(This.cDatapath) + This.cDataSource + ".DBF not ecist", 0, "Error")
>
> RETURN .F.
>ENDIF
>
>IF !FILE((FajlDOC)) THEN
> MESSAGEBOX("File " + FajlDOC + " does not exist!", 0, "Error")
>
> RETURN .F.
>ENDIF
>
>lcConnectionString = "DSN=DBASE Files - Word;UID=;PWD=;SourceDB=" + This.cDataPath + ";SourceType=DBF;Exclusive=No;BackgroundFetch=Yes;Collate=MACHINE;Null=Yes;Deleted=Yes;"
>
>*On Error Do DummyError
>oWord = GetObject("","Word.Application")
>
>IF TYPE("oWord") != "O" Then
> oWord = CreateObject("Word.Application")
> IF TYPE("oWord") !="O" Then
> MESSAGEBOX("Could not start WORD", 0, "Error")
>
> RETURN .F.
> ENDIF
>ENDIF
>
>WITH oWord
> .visible=.t.
>ENDWITH
>
>lnSelectArea=select()
>oWord.Documents.Open((FajlDOC), .F., .F., .F., "", "", .F., "", "", 0)
>oFormLetter = oWord.ActiveDocument
>
>oWord.ActiveDocument.MailMerge.OpenDataSource(lcFilename)
>
>WITH oWord.ActiveDocument.MailMerge
> .Destination = 0
> .MailAsAttachment = .F.
> .MailAddressFieldName = ""
> .MailSubject = ""
> .SuppressBlankLines = .F.
> WITH .DataSource
> .FirstRecord = 1
> .LastRecord = -16
> ENDWITH
> .Execute(.T.)
>ENDWITH
>
>oFormLetter.Close(0)
>
>IF THIS.lSave and !EMPTY(This.cSaveAsName) THEN
> IF !EMPTY(This.cSaveAsFolder) THEN
> oWord.ChangeFileOpenDirectory(This.cSaveAsFolder)
> ENDIF
>
> oWord.ActiveDocument.SAVEAS(This.cSaveAsName, 0)
>ENDIF
>
>
>
>Error appears on OPEN line of code. Error message is something like "file xx.doc does not exist" but there is xx.doc for sure.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only