Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Problem with automating mail merge
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 OLEDBatabase 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 |
#2
|
|||
|
|||
Hi ?B?SGVhdGhlck8=?=,
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. If you're running this macro within the Excel environment, then you need to ask this in an Excel newsgroup. To stop the people there from knee-jerking you back here, mention the problem with the personal.xls FIRST, and in the subject line. Then go on to say it's happening when you run code to automate Word, and post the code. Don't forget to mention which version of Office you're using :-) Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#3
|
|||
|
|||
Actually I am running the macro in word and accessing the excel application
through it. However I think I now know why the mail merge is bombing out and I am getting weird error messages that have nothing to do with what is really going on, it is an excel thing though so I will try there. Thanks for your help Heather "Cindy M -WordMVP-" wrote: Hi ?B?SGVhdGhlck8=?=, 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. If you're running this macro within the Excel environment, then you need to ask this in an Excel newsgroup. To stop the people there from knee-jerking you back here, mention the problem with the personal.xls FIRST, and in the subject line. Then go on to say it's happening when you run code to automate Word, and post the code. Don't forget to mention which version of Office you're using :-) Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
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 |