Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word merge
Message
De
25/03/2004 09:07:06
 
 
À
25/03/2004 08:01:28
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
00889545
Message ID:
00889566
Vues:
22
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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform