E
Erick C
Hello everybody -
I am having a problem with a bit of code, and I am hoping someone may
be able to help me out. The code currently opens a window to select
the path to save the exported file. It then takes two tables in the
database and exports the data into individual worksheets. I can get
the data to export into the worksheets, but I am running into problems
with the name of the second worksheet. When I open the Excel file I
get an error:
"Excel found unreadable content in 'filename.xls'. Do you want to
recover contents of this workbook?
When I click on Yes a repairs window opens and it says "Renamed
Invalid Sheet Name".
I am guessing it does not like the name of the second worksheet that I
am trying to export, since I use this same code to export a single
table with no problems. My code is below:
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
Dim fso As New FileSystemObject
strBrowseMsg = "Select the folder where the Cycle Count Analysis file
will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
strTable = "Location Analysis Recalculation"
strFile = Format$(Date, "Medium Date") & " Revised Cycle Count
Analysis.xls"
strPathFile = fso.BuildPath(strPath, strFile)
MsgBox strPathFile
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTable, strPathFile
strTable = "Location Analysis Summary for Finance"
strFile = Format$(Date, "Medium Date") & " Revised Cycle Count
Analysis.xls"
strPathFile = fso.BuildPath(strPath, strFile)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, , "'Cycle Count Overview'"
MsgBox "Revised Cycle Count Analysis File Has Been Exported.",
vbOK, "Status"
Can someone please help me figure this out?
Thank you!
I am having a problem with a bit of code, and I am hoping someone may
be able to help me out. The code currently opens a window to select
the path to save the exported file. It then takes two tables in the
database and exports the data into individual worksheets. I can get
the data to export into the worksheets, but I am running into problems
with the name of the second worksheet. When I open the Excel file I
get an error:
"Excel found unreadable content in 'filename.xls'. Do you want to
recover contents of this workbook?
When I click on Yes a repairs window opens and it says "Renamed
Invalid Sheet Name".
I am guessing it does not like the name of the second worksheet that I
am trying to export, since I use this same code to export a single
table with no problems. My code is below:
Dim strPathFile As String, strFile As String, strPath As String
Dim strTable As String, strBrowseMsg As String
Dim blnHasFieldNames As Boolean
Dim fso As New FileSystemObject
strBrowseMsg = "Select the folder where the Cycle Count Analysis file
will be created:"
strPath = BrowseFolder(strBrowseMsg)
If strPath = "" Then
MsgBox "No folder was selected.", vbOK, "No Selection"
Exit Sub
End If
strTable = "Location Analysis Recalculation"
strFile = Format$(Date, "Medium Date") & " Revised Cycle Count
Analysis.xls"
strPathFile = fso.BuildPath(strPath, strFile)
MsgBox strPathFile
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTable, strPathFile
strTable = "Location Analysis Summary for Finance"
strFile = Format$(Date, "Medium Date") & " Revised Cycle Count
Analysis.xls"
strPathFile = fso.BuildPath(strPath, strFile)
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
strTable, strPathFile, , "'Cycle Count Overview'"
MsgBox "Revised Cycle Count Analysis File Has Been Exported.",
vbOK, "Status"
Can someone please help me figure this out?
Thank you!