Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to handle "Invalid Worksheet Name" error programatically in VB

Hi,
I am trying to open an existing excel workbook. It pops up an error
stating that
Errors were detected in 1598.xls but Microsoft Office Excel was able to
open the file by making the repairs listed below. Save the file to make these
repairs permanent. Renamed invalid sheet name.

This message is popped up when the XLS file has work sheet with the name
like rpt:coursedetails etc.,

When trying to open this workbook, programmatically in VB.Net, the following
exception is raised:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in ExcelObjetCreation.exe

Additional information: Exception from HRESULT: 0x800A03EC.

Could you please tell me how this exception can be handled?

DO THERE IS ANY WAY

The code that i have written to open a currepted file is as below

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim xlApp As New Excel.Application
Dim xlworkBook As Workbook
Dim xlSheet As Worksheet
Dim ExcelFile_Path As String = "C:\XLReports\913.xls"
xlApp = CreateObject("Excel.Application")
xlSheet = xlApp.ActiveSheet()
MsgBox(xlSheet.Name)
xlworkBook = xlApp.Workbooks.Open(ExcelFile_Path)
MsgBox(xlworkBook.Name)
xlSheet = xlworkBook.Sheets(1)
MsgBox(xlSheet.Name)
xlSheet.Name = "Mysheet"
MsgBox(xlSheet.Name)

End Sub

I get an error at the following code
xlworkBook = xlApp.Workbooks.Open(ExcelFile_Path)


I feel like that its not possible to open a workbook which has a corrupted
sheetname.
How do microsoft open such file and ask for renaming it,and rename it?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default How to handle "Invalid Worksheet Name" error programatically in VB

Here is the solution

Case "EXCEL"

strFullPath = strSpoolPath & strReportID & ".xls"

strOutputFormat = Constants.acFormatXLS

If InStr(strRepName, ":") Then

Dim strNewRepName As String

strNewRepName = Replace(strRepName, ":", "_")

objAcc.DoCmd.CopyObject(, strNewRepName,
AcObjectType.acReport, strRepName)


objAcc.DoCmd.OutputTo(AcOutputObjectType.acOutputR eport, strNewRepName,
Constants.acFormatXLS, strFullPath, False)

objAcc.DoCmd.DeleteObject(AcObjectType.acReport,
strNewRepName)

Else


objAcc.DoCmd.OutputTo(AcOutputObjectType.acOutputR eport, strRepName,
Constants.acFormatXLS, strFullPath, False)

End If

strFilename = strReportID & ".xls"


"Jimmy Jose" wrote:

Hi,
I am trying to open an existing excel workbook. It pops up an error
stating that
Errors were detected in 1598.xls but Microsoft Office Excel was able to
open the file by making the repairs listed below. Save the file to make these
repairs permanent. Renamed invalid sheet name.

This message is popped up when the XLS file has work sheet with the name
like rpt:coursedetails etc.,

When trying to open this workbook, programmatically in VB.Net, the following
exception is raised:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in ExcelObjetCreation.exe

Additional information: Exception from HRESULT: 0x800A03EC.

Could you please tell me how this exception can be handled?

DO THERE IS ANY WAY

The code that i have written to open a currepted file is as below

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim xlApp As New Excel.Application
Dim xlworkBook As Workbook
Dim xlSheet As Worksheet
Dim ExcelFile_Path As String = "C:\XLReports\913.xls"
xlApp = CreateObject("Excel.Application")
xlSheet = xlApp.ActiveSheet()
MsgBox(xlSheet.Name)
xlworkBook = xlApp.Workbooks.Open(ExcelFile_Path)
MsgBox(xlworkBook.Name)
xlSheet = xlworkBook.Sheets(1)
MsgBox(xlSheet.Name)
xlSheet.Name = "Mysheet"
MsgBox(xlSheet.Name)

End Sub

I get an error at the following code
xlworkBook = xlApp.Workbooks.Open(ExcelFile_Path)


I feel like that its not possible to open a workbook which has a corrupted
sheetname.
How do microsoft open such file and ask for renaming it,and rename it?


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error "invalid data source reference" for pivot table Manny Excel Worksheet Functions 6 April 5th 23 02:58 PM
error: "invalid character in text conent" How do I open this file RTH Excel Discussion (Misc queries) 5 April 23rd 06 03:04 PM
"Invalid Web Query" error on opening a 2003 worksheet Linus Excel Discussion (Misc queries) 0 February 21st 06 04:55 PM
Excel 97 ADODB Recordset.Find "Invalid Use" error Robin Hammond[_2_] Excel Programming 1 August 27th 04 12:47 PM
Need help in excel with "Statement invalid outside Type block. " error Brent[_6_] Excel Programming 3 January 17th 04 03:03 AM


All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright 2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"