![]() |
Urgent info. on opening a mail merge with the datasource open
There is a great lag in opening these documents. Read the
information below. This is opening another spreadsheet and closing the current one that will allow me to run the 2nd macro. Sub Rectangle1_Click() Workbooks.Open ("H:\Created Projects\Excel\xxxxx\To get doc open.xls") Workbooks("xxxxx.xls").Activate ActiveWorkbook.Close (Yes) End Sub This is where it's taking a long time to open the word doc. (that's merged) and the excel spreadsheet with the merged data. Sub Open_RetentionDoc() Dim appWD As Object Dim wdDoc As Document Set appWD = CreateObject("Word.Application") appWD.Visible = True appWD.ChangeFileOpenDirectory ActiveWorkbook.Path appWD.Documents.Open Filename:="H:\Created Projects\Word\xxxxx\xxxxx Project\letters\xxxxx Letter.doc" Set wdDoc = appWD.ActiveDocument ActiveWorkbook.Close (No) End Sub This is the macro that sends the merged information to a new document and closes the mail merged doc. How can I keep the excel spreadsheet open at this point? When I have the merged doc. to close it automatically closes the spreadsheet, too. docname = ActiveDocument.MailMerge.DataSource.DataFields ("Name").Value x = ActiveDocument.MailMerge.DataSource.DataFields ("Records").Value With ActiveDocument.MailMerge .Destination = wdSendToNewDocument .SuppressBlankLines = True With .DataSource .FirstRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord .LastRecord = ActiveDocument.MailMerge.DataSource.ActiveRecord End With .Execute Pause:=False End With Documents("xxxxx Letter.doc").Close (Yes) ActiveDocument.Close (Yes) Application.Quit End Sub |
All times are GMT +1. The time now is 05:07 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com