Reply
 
Thread Tools Display Modes
  #1   Report Post  
HeatherO
 
Posts: n/a
Default 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   Report Post  
Cindy M -WordMVP-
 
Posts: n/a
Default

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   Report Post  
HeatherO
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge Word 2003 Issue S.Nicks Mailmerge 5 February 20th 09 01:55 AM
Mail merge data source problem campwes Mailmerge 1 January 25th 05 07:16 PM
Word-Excel 2003 - Mail Merge Recipients problem AYager Mailmerge 2 January 11th 05 04:11 AM
Mail Merge Problem w/ MS Word 2000 pkampa(removethis)@optonline.net Mailmerge 2 December 28th 04 08:51 PM
Mail Merge Problem Cindy M -WordMVP- Mailmerge 0 November 30th 04 05:25 PM


All times are GMT +1. The time now is 08:01 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"