Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read Excel Worksheet Names 1

Status
Not open for further replies.

mmogul

IS-IT--Management
Dec 1, 2003
218
US
I have a program that is processing multiple worksheets in an excel spreadsheet. It appears that an excel user can use the "#" sign in the worksheet name. But when access tries to read it,

The microsoft database jet engine could not read the object ... it then gives the object name leaving out the # sign.

Does anyone have any ideas to get around this issue, other than telling the user not to use the # sign in the worksheet name?

The code is essentially this:

strFileName = filePath & fileName

Set objWorkbook = objExcel.Workbooks.Open(strFileName)
Set colWorksheets = objWorkbook.Worksheets

For Each objWorksheet In colWorksheets....

DoCmd.TransferSpreadsheet acImport, 8, "tblTempMfgProductData", strFileName, False, strWorkSheetName


Thanks
 
How about a work-around?

Code:
    For Each objWorksheet In objWorkbook.Worksheets
        If InStr(objWorksheet.Name, "#") > 0 Then
            a = objWorksheet.Name
            objWorksheet.Name = Replace(a, "#", "x")
        End If
        
        DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, objWorksheet.Name, strFileName, False, _
             objWorksheet.Name & "$"
            
        If a <> "" Then
           objWorksheet.Name = a
           a = ""
        End If
   
    Next
 
Sounds good. I'll give it a try. I had thought about changing the name -- but I thought if I changed the name, the program wouldn't find the spreadsheet.

Thanks.
 
Why do you append the "$" to the objWorksheet.Name?

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top