Home |
Search |
Today's Posts |
#1
![]() |
|||
|
|||
![]()
I wanted to automate my mail merge and there is a problem it appears when I
am running my macro. I have accessed excel through word using late binding and stored all the mail merge data into 2 excel tables (one french, one english). I prompt for the english and french data files to use for the mail merge. When running it for some reason I get an error about another macro called personal.xls in my excel application stating the file is in use and locked for editing. This macro though is seperate(the personal.xls) from the mail merge macro but somehow it is causing interference. A sample of my mail merge is below: (any suggestions are appreciated) Sub do_mail_merge(mrgfile_eng, mrgfile_fre) Dim docname As String Dim dtasrc As String Dim filecnt As Long XLShtEng.Activate lislrow = XLShtEng.Range("A65536").End(xlUP).Row If lislrow = 2 Then docname = mrgfile_eng dtasrc = "C:\Model Pilot\EngMrg.xls" filecnt = 1 GoTo labelZ End If labelZ: Documents.Open (docname) 'Documents(docname).Activate With ActiveDocument.MailMerge .OpenDataSource name:=dtasrc, _ ConfirmConversions:=False, ReadOnly:=True, LinkToSource:=True, _ AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="", _ WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _ Format:=wdOpenFormatAuto, Connection:= _ "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";Us er ID=Admin;Data Source=dtasrc;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB ![]() Password="""";Jet OLEDB:Engine Type=3" _ , SQLStatement:="SELECT * FROM `Sheet1$`", SQLStatement1:="" .Destination = wdSendToNewDocument .Execute End With Documents(docname).Activate ActiveDocument.Close wdDoNotSaveChanges If filecnt 2 Then lislrow = 0 XLShtFre.Activate lislrow = XLShtFre.Range("A65536").End(xlUP).Row If lislrow = 2 Then docname = mrgfile_fre dtasrc = "C:\Model Pilot\FreMrg.xls" filecnt = filecnt + 1 GoTo labelZ End If End If XLBookENG.Close savechanges:=False XLBookFRE.Close savechanges:=False AppXL.Quit Set XLBookENG = Nothing Set XLBookFRE = Nothing Set XLShtEng = Nothing Set XLShtFre = Nothing End Sub Thanks, Heather |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Mail Merge Word 2003 Issue | Mailmerge | |||
Mail merge data source problem | Mailmerge | |||
Word-Excel 2003 - Mail Merge Recipients problem | Mailmerge | |||
Mail Merge Problem w/ MS Word 2000 | Mailmerge | |||
Mail Merge Problem | Mailmerge |