Getting Error Code:5922 when running word mail merge on Office XP 
Author Message
 Getting Error Code:5922 when running word mail merge on Office XP

Hi

I am getting error Code = 5922 "Word was unable to open
the datasource" when running mail merge using MS-Word on
Office XP. I can run the same code on WIN2K and it's
running fine.

I am getting information from the SQL Server in my visual
basic code.Here is code where I am getting error on
OpenDataSource method.

Thanks in advance for any help.
DShah

Public Function mergeThis()
Dim endDate
On Error GoTo errorhandler
With ActiveDocument.MailMerge
.MainDocumentType = wdFormLetters

constr = "UID=florist;PWD=;DSN=FTDFlorist;DATABASE=Store"
        sqlStmt = "SELECT * from FTD.recpInfo"

.OpenDataSource Name:="c:\WingsTemplate.txt",
Connection:=constr, SQLStatement:=sqlStmt

        .Destination = wdSendToNewDocument
        .MailAsAttachment = False
        .MailAddressFieldName = ""
        .MailSubject = ""
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = wdDefaultFirstRecord
            .LastRecord = wdDefaultLastRecord
        End With
        .Execute Pause:=True
    End With    
    Exit Function

errorhandler:

    ' Some error handling code

    frmFinish.Hide
    Unload frmFinish
    frmGetStartDate.Show

End Function



Sat, 05 Mar 2005 06:16:35 GMT  
 Getting Error Code:5922 when running word mail merge on Office XP
Hello DShah,

See the following KB article, specifically where it has "Method 2: Turn Off
the Option to Hide File Extensions:"

Q224056 - WD2000: Error Message: Word Was Unable to Open the Data Source
http://support.microsoft.com/support/kb/articles/q224/0/56.asp

Does "turning off the option to hide file extensions" make the problem go
away?  A different workaround you can try is to remove the ODBC text
driver.  That way, only the native "Text Files(*.txt)" option is available
for Word mail merge.

Another way to perform a mail merge is shown in the following article,
where you put your source data into a Word document and use that document
as the source, instead of using the text file directly as the source:

Q220607 - HOWTO: Automate Word to do Mail Merge from Visual Basic
http://support.microsoft.com/support/kb/articles/q220/6/07.asp

For information and sample code for integrating Office with Visual Basic,
Visual C++, Internet Scripts, and other programming languages, please see
http://msdn.microsoft.com/library/techart/VSOfficeDev.htm. This site
contains the most up-to-date information for using developer tools for
Office integration and extensibility.

HTH,
 Greg Ellison
 Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.

Are you secure? For information about the Microsoft Strategic Technology
Protection Program and to order your FREE Security Tool Kit, please visit
http://www.microsoft.com/security.

--------------------

Quote:

>Subject: Getting Error Code:5922 when running word mail merge on Office XP
>Date: Mon, 16 Sep 2002 15:16:35 -0700

>Hi

>I am getting error Code = 5922 "Word was unable to open
>the datasource" when running mail merge using MS-Word on
>Office XP. I can run the same code on WIN2K and it's
>running fine.

>I am getting information from the SQL Server in my visual
>basic code.Here is code where I am getting error on
>OpenDataSource method.

>Thanks in advance for any help.
>DShah

>Public Function mergeThis()
>Dim endDate
>On Error GoTo errorhandler
>With ActiveDocument.MailMerge
>.MainDocumentType = wdFormLetters

>constr = "UID=florist;PWD=;DSN=FTDFlorist;DATABASE=Store"
>        sqlStmt = "SELECT * from FTD.recpInfo"

>.OpenDataSource Name:="c:\WingsTemplate.txt",
>Connection:=constr, SQLStatement:=sqlStmt

>        .Destination = wdSendToNewDocument
>        .MailAsAttachment = False
>        .MailAddressFieldName = ""
>        .MailSubject = ""
>        .SuppressBlankLines = True
>        With .DataSource
>            .FirstRecord = wdDefaultFirstRecord
>            .LastRecord = wdDefaultLastRecord
>        End With
>        .Execute Pause:=True
>    End With    
>    Exit Function

>errorhandler:

>    ' Some error handling code

>    frmFinish.Hide
>    Unload frmFinish
>    frmGetStartDate.Show

>End Function



Wed, 09 Mar 2005 03:43:22 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Automating Mail Merge with VB.Net and Office XP and Office 2000 produces mixed results

2. Mail Merge in Office XP

3. Office XP Mail Merge issue Insertdatabase issue and problems with copying a macro

4. Office XP Run Time Error after upgrade from Office 2000

5. Word Mail Merge Err - Word could not merge...

6. vba code to Fax Merge in MS WORD XP

7. Word Templates with VBA code running very slow in Word XP

8. Getting mail merge fields back from Word

9. How to: Fax Merge for MS WORD XP , code in vb.NET

10. newbie needs code help for word mail merge

11. VB Code for Word Mail Merge Wizerd

12. VB run time error 1004 under XP Office

 

 
Powered by phpBB® Forum Software