Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
tim tim is offline
external usenet poster
 
Posts: 105
Default Mail Merge Error

Hi
I have a sheet that I use to generate costs. I wrote a
bit of VBA to mail merge the info into a word document.
This worked fine, then I did not use the sheet for a
while.
When I came to use it again, on pressing the button to
invoke the mail merge, I got the following error:
Runtime Error 5273 Application-Defined or Object-Defined
error

Dont understnad how this has come about as I've not
changed anything!
Any reason why?!?!?(code below)
TIA
Tim


Sub PopulateProposal()
'On Error GoTo errorHandler
Dim wdApp As Word.Application
Dim myDoc As Word.Document
Dim myRange As Word.Range

'open Word
Set wdApp = New Word.Application
With wdApp
.Visible = True
.WindowState = wdWindowStateMaximize
End With

'open Template
Worksheets("Deployment Input").Activate 'activate the
sheet with path details
Curfile = Range("H18") 'the path details of the
template
Set myDoc = wdApp.Documents.Open(Curfile)
Set myRange = myDoc.Words(1)

'mail merge
Curfile = ActiveWorkbook.Path + "\" + ActiveWorkbook.Name
With ActiveDocument.MailMerge
'load data range from spreadsheet
.MainDocumentType = wdCatalog
.OpenDataSource Name:=Curfile _
, ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"DSN=Excel Files;DBQ=" + Curfile
+ ";DriverId=22;MaxBufferSize=512;PageTimeout=5; " _
, SQLStatement:="SELECT * FROM
`MailMergeField`"
'do actual mail merge
'.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=True
End With
..


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell 255 Character - Error Mail merge to MS word. Randoo Excel Discussion (Misc queries) 3 January 8th 07 06:09 PM
Code launches Mail Merge but disables the Mail Merge austris Excel Discussion (Misc queries) 0 October 14th 06 01:11 AM
mail merge error Antz Excel Discussion (Misc queries) 1 January 11th 05 04:13 PM
Mail Merge Error Tim Excel Programming 0 August 2nd 04 04:50 PM
Mail merge error Robert Couchman[_5_] Excel Programming 0 March 5th 04 12:56 PM


All times are GMT +1. The time now is 12:42 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"