S
Straws
Hi,
I am automating a mailmerge from a datasheet in excel to a word document.
The user enters data into the excel spreadsheet and then uses a userform to
activate the mailmerge process.
my code is interrupted when the Word main document is opened and the
datasource is being defined. Word pops up a window called "Select Table"
which (surprise surprise) allows you to select which worksheet the data is on
in the excel workbook.
I can't figure out how to automate this selection... I want to be selecting
"sheet1"... and it's the only sheet in the workbook so I don't understand why
it doesn't just select it automatically.
I won't post all the code at the moment cause I don't think it's entirely
relevant to the problem, but if anyone wants it then I would be happy to.
Here is the part that seems to be relevant.
With appWD.ActiveDocument.MailMerge
.OpenDataSource Name:=(Workbooks("whatson data").Path & "\Guts - do_
not tamper\Data Source.xls")
.DataSource.FirstRecord = 1
.DataSource.LastRecord = r - 3
.Destination = wdSendToNewDocument
.Execute
End With
I have searched the message board here and at mrexcel but can find no-one
who has had a similar problem... which leads me to suspect I'm doing
something wrong. However, time (and your responses) will tell.
Thanks SO much to anyone who can help me with this one.
Straws.
I am automating a mailmerge from a datasheet in excel to a word document.
The user enters data into the excel spreadsheet and then uses a userform to
activate the mailmerge process.
my code is interrupted when the Word main document is opened and the
datasource is being defined. Word pops up a window called "Select Table"
which (surprise surprise) allows you to select which worksheet the data is on
in the excel workbook.
I can't figure out how to automate this selection... I want to be selecting
"sheet1"... and it's the only sheet in the workbook so I don't understand why
it doesn't just select it automatically.
I won't post all the code at the moment cause I don't think it's entirely
relevant to the problem, but if anyone wants it then I would be happy to.
Here is the part that seems to be relevant.
With appWD.ActiveDocument.MailMerge
.OpenDataSource Name:=(Workbooks("whatson data").Path & "\Guts - do_
not tamper\Data Source.xls")
.DataSource.FirstRecord = 1
.DataSource.LastRecord = r - 3
.Destination = wdSendToNewDocument
.Execute
End With
I have searched the message board here and at mrexcel but can find no-one
who has had a similar problem... which leads me to suspect I'm doing
something wrong. However, time (and your responses) will tell.
Thanks SO much to anyone who can help me with this one.
Straws.