Connection String Syntax Error

Hi, I am fairly new to VBA

I have some syntax problems that I do not understand with the connection strings that you give.
For example for XL 2007
With the following, the first ( which you give ) and the Third give Syntax errors.
The others I found by trial and error seem to work
Can you explain the required syntax here.
Thanks
Alan

objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties="Excel 12.0 Xml;HDR=YES;IMEX=1";"   '  Compile Error
objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties=""Excel 12.0 Xml;HDR=YES;IMEX=1"";"   '  OK
objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties=Excel 12.0 Xml;HDR=YES;IMEX=1;"    '  Compile Error
objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;" & "Extended Properties=Excel 12.0 Xml;"    '  OK
objConn.Open "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\myFolder\myExcel2007file.xlsx;Extended Properties" & "=Excel 12.0 Xml;"   '  OK

0 answers