Help with Selecting Merge Table

  • Thread starter Thread starter Jenny B.
  • Start date Start date
J

Jenny B.

Hi All,

I setup a Macro that opens a text file into Excel and then immediately
formats the data and lastly merges the data to an already formatted Word
Merge doc.

My question is, what can I add to the below code to make the routine
automatically select the merge table vs. the Macro pausing and having the
user select? The table (tab) from Excel this is merging from is named
“MergeHomeâ€.

Thank you in advance for any thoughts – Jenny B.


Sub Word()

Application.ScreenUpdating = False
Call JLBtheGreat
strLetterPath = "C:\Documents and Settings\jenny\Desktop\Transmittal.doc"
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
Set wdDoc = appWD.Documents.Open(Filename:=strLetterPath)
wdDoc.MailMerge.OpenDataSource Name:="C:\Documents and
Settings\jenny\Desktop\Splash Screen.xls", _
ConfirmConversions:=False, _
Connection:="", SQLStatement:="", SQLStatement1:=""

Application.ScreenUpdating = True

appWD.Run "MergeLines"

End Sub
 
I went to Word and looked at the help for opendatasource. the help said to
put in the connect the word table followed by the table name when using
access. Since a table in Access is the same as a worksheet in excel that is
the answer

from
Connection:=""
to
Connection:="Table Sheet1" or equivalent.
 
Back
Top