VBA Create Recordset when the workbook path has a single quote

Trebor76

Well-known Member
Joined
Jul 23, 2007
Messages
5,270
Office Version
  1. 365
Platform
  1. Windows
Hello all,

I'm trying to create a recordset from a tab in a workbook that's been saved on a server drive. Part of the server path has a single quote which causes an issue when I try and pass my SQL statement for the recordset as a single quote denotes the start of a field (column) in SQL. When I replace the single quote with double quotes (as I've done with fields before) the connection then fails as the code correctly says the path doesn't exist.

I've tried to use the Command function but as the headings are not in Row 1 that doesn't work as it doesn't support [Fn] referencing.

If the connection string could just be the workbook name (it is open) it would work but it needs the workbook's full name, so back to the original issue.

Does anyone have any ideas how I could make this work?

Thanks in advance,

Robert
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,215,006
Messages
6,122,665
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top