Hi! all,
I'm working with VB6 and Ecel 97 object library. I'm able to open up excel sheet using desired automation also giving a filename for the worksheet (using .Name property of worksheet) as well as Overall window name as the same. Please find the code below:
'**********************************************************
Public Sub ShowExcelFile()
On Error GoTo Sub_Err
Dim oXlApp As Object
Dim oXlBook As Object
Dim oXlSheet As Object
Screen.MousePointer = vbHourglass
Set oXlApp = CreateObject("Excel.Application", ""
Set oXlBook = oXlApp.Workbooks.Add
Set oXlSheet = oXlBook.Worksheets("Sheet1"
oXlApp.DisplayAlerts = False
oXlBook.Worksheets("Sheet2"
.Delete
oXlBook.Worksheets("Sheet3"
.Delete
oXlApp.DisplayAlerts = True
oXlSheet.Name = "MyOrderFile1"
oXlBook.Application.ActiveWindow.Caption = _
"MyOrderFile1"
oXlApp.ActiveWindow.DisplayGridlines = Not _
(oXlApp.ActiveWindow.DisplayGridlines)
oXlApp.WindowState = 3
oXlBook.Application.Visible = True
Set oXlSheet = Nothing
Set oXlBook = Nothing
Set oXlApp = Nothing
Sub_Close:
Set oXlSheet = Nothing
Set oXlBook = Nothing
Set oXlApp = Nothing
Screen.MousePointer = vbDefault
Exit Sub
Sub_Err:
MsgBox Err.Description, vbOKOnly, "Open Excel"
GoTo Sub_Close
End Sub
'**********************************************************
so when you run this, you'll see th eexcel opened with MyOrderFile1 as sheet and window name. Now when i click save, it shows a SaveAs dialog and the bworkbook name as Book1 or whatever is the latest book number. My question is how to get the save as name as the same that i gave for the worksheet (i.e. 'MyOrderFile1' instead of 'Book1' in the SaveAs dialo box?)
please let me know.
thanks in advance.
regards,
netizen
I'm working with VB6 and Ecel 97 object library. I'm able to open up excel sheet using desired automation also giving a filename for the worksheet (using .Name property of worksheet) as well as Overall window name as the same. Please find the code below:
'**********************************************************
Public Sub ShowExcelFile()
On Error GoTo Sub_Err
Dim oXlApp As Object
Dim oXlBook As Object
Dim oXlSheet As Object
Screen.MousePointer = vbHourglass
Set oXlApp = CreateObject("Excel.Application", ""
Set oXlBook = oXlApp.Workbooks.Add
Set oXlSheet = oXlBook.Worksheets("Sheet1"
oXlApp.DisplayAlerts = False
oXlBook.Worksheets("Sheet2"
oXlBook.Worksheets("Sheet3"
oXlApp.DisplayAlerts = True
oXlSheet.Name = "MyOrderFile1"
oXlBook.Application.ActiveWindow.Caption = _
"MyOrderFile1"
oXlApp.ActiveWindow.DisplayGridlines = Not _
(oXlApp.ActiveWindow.DisplayGridlines)
oXlApp.WindowState = 3
oXlBook.Application.Visible = True
Set oXlSheet = Nothing
Set oXlBook = Nothing
Set oXlApp = Nothing
Sub_Close:
Set oXlSheet = Nothing
Set oXlBook = Nothing
Set oXlApp = Nothing
Screen.MousePointer = vbDefault
Exit Sub
Sub_Err:
MsgBox Err.Description, vbOKOnly, "Open Excel"
GoTo Sub_Close
End Sub
'**********************************************************
so when you run this, you'll see th eexcel opened with MyOrderFile1 as sheet and window name. Now when i click save, it shows a SaveAs dialog and the bworkbook name as Book1 or whatever is the latest book number. My question is how to get the save as name as the same that i gave for the worksheet (i.e. 'MyOrderFile1' instead of 'Book1' in the SaveAs dialo box?)
please let me know.
thanks in advance.
regards,
netizen