cvincent
Board Regular
- Joined
- Aug 28, 2011
- Messages
- 66
If someone has a solution to this problem, I would be very grateful!! I'm no expert in VBA, so any help you can provide would be most helpful.
I have my data in Excel 2007, protected by a password to open file, and read only password. I have a form in Word 2007.
The user opens the Excel file first, selects the data, then clicks a macro that is set to open the Word document, and upon Open runs the Word macro to merge the selected data into the form. It works fine as long as I do NOT open the Excel file as "read only", i.e. I must enter both passwords to make it work. I need users to open the Excel file as a "Read Only".
If I open the Excel file as a "read only", however, the Word macro will not run. It is getting hung up on the connection.
I am getting the following error message: "Error has occurred: External table is not in the specified format"
Following is the part of the macro that is causing the problem:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"F:\EMERGENCY CONTACTS\DATABASE-EMERGENCY CONTACTS (rev 6-2013).xlsm" _
, ConfirmConversions:=False, ReadOnly:=True, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="XYZ", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=F:\EMERGENCY CONTACTS\DATABASE-EMERGENCY CONTACTS (rev 6-2013).xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB" _
, SQLStatement:="SELECT * FROM `'Selected Contacts$'`", SQLStatement1:="" _
, SubType:=wdMergeSubTypeAccess
Thank you!!
I have my data in Excel 2007, protected by a password to open file, and read only password. I have a form in Word 2007.
The user opens the Excel file first, selects the data, then clicks a macro that is set to open the Word document, and upon Open runs the Word macro to merge the selected data into the form. It works fine as long as I do NOT open the Excel file as "read only", i.e. I must enter both passwords to make it work. I need users to open the Excel file as a "Read Only".
If I open the Excel file as a "read only", however, the Word macro will not run. It is getting hung up on the connection.
I am getting the following error message: "Error has occurred: External table is not in the specified format"
Following is the part of the macro that is causing the problem:
ActiveDocument.MailMerge.OpenDataSource Name:= _
"F:\EMERGENCY CONTACTS\DATABASE-EMERGENCY CONTACTS (rev 6-2013).xlsm" _
, ConfirmConversions:=False, ReadOnly:=True, LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="XYZ", PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="", Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=Microsoft.ACE.OLEDB.12.0;User ID=Admin;Data Source=F:\EMERGENCY CONTACTS\DATABASE-EMERGENCY CONTACTS (rev 6-2013).xlsm;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:System database="""";Jet OLEDB:Registry Path="""";Jet OLEDB" _
, SQLStatement:="SELECT * FROM `'Selected Contacts$'`", SQLStatement1:="" _
, SubType:=wdMergeSubTypeAccess
Thank you!!