office 2000/nt & office2003/XP mailmerge

GaryB

Active Member
Joined
Feb 25, 2002
Messages
459
Hi,

Im having a little problem with a mailmerge I'm controling from Excel. To make it a little easier the users I'm doing this for are on a different OS, different version of Office, in a different office 250 miles away, and know even less about VBA than I do! Anyhoo here's my code- this is in a module in Excel


Code:
Sub CreateLetter()

Dim wdApp As Object
Set wdApp = CreateObject("Word.Application")
Dim LtrType As Integer
Dim myLetter As String

LtrType = Range("FT1Stat2")
If LtrType = 1 Then
myLetter = "h:\ftfaq.doc"
ElseIf LtrType = 2 Then
myLetter = "h:\statfaq.doc"

End If

On Error Resume Next
Set wdApp = GetObject("word.application")


If Err.Number <> 0 Then 'Word isn't already running
Set wdApp = CreateObject("Word.Application")
End If

wdApp.Visible = True
wdApp.Documents.Open myLetter


    With wdApp.ActiveDocument.MailMerge
        .Destination = 0      '0=wdSendToNewDocument
        .SuppressBlankLines = True
        With .DataSource
            .FirstRecord = 1    'wdDefaultFirstRecord
            .LastRecord = 1     'wdDefaultLastRecord
        End With
        .Execute Pause:=False
    End With

    
    If LtrType = 1 Then
        wdApp.Windows("ftfaq.doc").Close False
    ElseIf LtrType = 2 Then
        wdApp.Windows("statfaq.doc").Close False
    End If
    
    wdApp.Activate
   
   
End Sub



It works fine on my office machine (XP- office 2003) but when I send it to another office who use NT and Office 2000 it fails to produce the new document- stepping thru the code is pretty uneventful- no crashes or errors just that as I get to the last step of the With wdApp.ActiveDocument.MailMerge group my XP machine produces FormLetters1.doc as my merged document and the NT/2000 version just sits there defiantly not producing a new document! The next part then closes the merging document as it should.
I had issues with Early/Late binding, but I think I'm now fully late bound- I've got rid of all the default references and checked that the 2000 version isn't expecting word 11.0 object library- the code runs thru without erroring, just won't merge. The datafile is already linked to the word documents and when they open them manually the merge fields populate with the data so I don't think that is the problem- but on the basis that I can't see to be sure if there is a VBA way of attaching the datafile to the letter that might be worth doing just to be sure.

Can anyone see where I am going wrong, or give me any clues as to what the issue might be??

Thanks for your help

GaryB
 
Last edited:

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
Hi Gary,

Can you be sure the files "h:\ftfaq.doc" and "h:\statfaq.doc" actually exist at the remote location - on the designated paths?
 
Upvote 0
Hi Macropod,

yes, the files exist. I had the remote user step thru the macro and Word opens, the document opens, the mailmerge instructions all step thru, the document closes- it just doesn't do the kinda important bit of producing the new document!

Thanks

GaryB
 
Upvote 0
Hi Gary,

What happens if the users at the remote location open the files "h:\ftfaq.doc" and "h:\statfaq.doc" manually? Do they get any error messages? Are they able to execute the merge?
 
Upvote 0
They tell me yes, which is really confusing. That said, I am not exactly dealing with power users here so the reports could be wrong! I may have been too trusting of the info coming back. I'll have to talk someone thru a merge step by step and make absolutely sure that they are creating a new document and not just seeing the original populated with data.

I'll be back! ...

GaryB
 
Upvote 0

Forum statistics

Threads
1,225,415
Messages
6,184,856
Members
453,264
Latest member
AdriLand

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top