Apostrophe in the Excel worksheet name (1 Viewer)

mdo

Registered User.
Local time
Today, 10:28
Joined
Aug 17, 2003
Messages
13
Hi,

I'm importing from Excel to Access using the DoCmd.Transferspreadsheet command. It works except when there is an apostrophe in the Excel worksheet name. Is there a code to automatically remove the apostrophe?

Please help.

Thanks.
 

crosmill

Registered User.
Local time
Today, 16:28
Joined
Sep 20, 2001
Messages
285
Try useing double quotes to define your file name.

DoCmd.TransferSpreadsheet "MyFile'Name.xls"
 

mdo

Registered User.
Local time
Today, 10:28
Joined
Aug 17, 2003
Messages
13
Apostrophe In The Excel Worksheet name

Hi,

I already have double quote in between the file name. My syntax is below:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Toll Free Inventory", "c:\Tiger\Marita\Sears\Test.xls", True, All, useoa

Please help.

Thanks.
 

crosmill

Registered User.
Local time
Today, 16:28
Joined
Sep 20, 2001
Messages
285
There's no apostrophie in that file name. Can you post the line thats failing?
 

mdo

Registered User.
Local time
Today, 10:28
Joined
Aug 17, 2003
Messages
13
Apostrophe In Excel Worksheet Name

This is the line that's failing:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Toll Free Inventory", "c:\Tiger\Marita\Sears\Test.xls", True, All, useoa
 

crosmill

Registered User.
Local time
Today, 16:28
Joined
Sep 20, 2001
Messages
285
But there's no apostrophie in that file name, so how is it the apostrophie thats making it fail?
 

mdo

Registered User.
Local time
Today, 10:28
Joined
Aug 17, 2003
Messages
13
Apostrophe in Excel worksheet name

It is failing because the name of the worksheet of the excel file that I'm trying to import has an apostrophe in the name. The name of the worksheet is "TFN's 3Q" instead of the usual "Sheet1".

Please help.
 

crosmill

Registered User.
Local time
Today, 16:28
Joined
Sep 20, 2001
Messages
285
My appologies I thought it was the file name

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "TFN's 3Q", "c:\Tiger\Marita\Sears\Test.xls", True, All, useoa


I've had trouble with specifing worksheet names though, I've found that it doesn't really matter what worksheet name you specify it will only import the first sheet in the spreadsheet
 

mdo

Registered User.
Local time
Today, 10:28
Joined
Aug 17, 2003
Messages
13
Apostrophe in Excel worksheet name

It looks like you are replacing the name of the table to "TFN's 3Q". The actual name of the table is "Toll Free Inventory". "TFN's 3Q" is the name of the Excel worksheet.

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "TFN's 3Q", "c:\Tiger\Marita\Sears\Test.xls", True, All, useoa

I know it always import the first worksheet from Excel. It is doing that, but it doesn't like the name "TFN's 3Q" because of the apostrophe. It works ok if I manually remove the apostrophe.

Please help. Any idea?
 

crosmill

Registered User.
Local time
Today, 16:28
Joined
Sep 20, 2001
Messages
285
Ahh ok I didn't check the spec.

You've written "All" but in the spec it tells you to leave it blank if you want to import the whole spreadsheet.
 

crosmill

Registered User.
Local time
Today, 16:28
Joined
Sep 20, 2001
Messages
285
found this as well

Range The range of cells to import or link. Leave this argument blank to import or link the entire spreadsheet. You can type the name of a range in the spreadsheet or specify the range of cells to import or link, such as A1:E25 (note that the A1..E25 syntax does not work in Access 97 or later). If you are importing from or linking to an Excel version 5.0 or later spreadsheet, you can prefix the range with the name of the worksheet and an exclamation point; for example, Budget!A1:C7.
 

Users who are viewing this thread

Top Bottom