Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with hiden workbooks
I am using a hidden workbook to generate graphs using Excel. I was having a
problem adding a label to the chart while the workbook was hidden. So, I installed SP1 for Office 2003 to see if that would fix the problem. Now, I can't even add a chart to the workbook when it is hidden. I am running on Windows XP SP2. I would appreciate any help. Included is code that can reproduce the problem: '----------------------------------------------------------------------- Option Explicit Private Const msoOrientationHorizontal As Long = 1 Private Const msoTrue As Long = -1 Private Sub Form_Load() Dim oExcelApp As Object Dim oExcelBook As Object Dim oExcelChart As Object Dim oExcelShape As Object Set oExcelApp = CreateObject("Excel.Application") Set oExcelBook = oExcelApp.Workbooks.Add ' Comment out the following line and everything will work oExcelBook.Windows(1).Visible = False ' If SP1 for office 2003 is installed, this line fails with the following error ' Run-time error '-2147417851 (80010105)': Method 'Add' of object 'Sheets' failed Set oExcelChart = oExcelBook.Charts.Add ' If SP1 is not installed, this line fails with the following error ' "run-time error '1004': Application-defined or object-defined error" Set oExcelShape = oExcelChart.Shapes.AddLabel(msoOrientationHorizont al, 0, 0, 10, 10) oExcelShape.TextFrame.Characters.Text = "Hello" oExcelShape.Line.Visible = msoTrue oExcelShape.TextFrame.AutoSize = True oExcelBook.Close False oExcelApp.Quit Set oExcelShape = Nothing Set oExcelChart = Nothing Set oExcelBook = Nothing Set oExcelApp = Nothing Unload Me End Sub |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with hiden workbooks
Your code ran fine for me with and without commenting out the line. I ran
the code from Word since I don't have VB6 installed but that shouldn't make any difference. I'm not sure why you want to hide the window though since Excel itself is not visible so there's nothing to see in any case. -- Jim "Daniel Knueven" wrote in message ... I am using a hidden workbook to generate graphs using Excel. I was having a problem adding a label to the chart while the workbook was hidden. So, I installed SP1 for Office 2003 to see if that would fix the problem. Now, I can't even add a chart to the workbook when it is hidden. I am running on Windows XP SP2. I would appreciate any help. Included is code that can reproduce the problem: '----------------------------------------------------------------------- Option Explicit Private Const msoOrientationHorizontal As Long = 1 Private Const msoTrue As Long = -1 Private Sub Form_Load() Dim oExcelApp As Object Dim oExcelBook As Object Dim oExcelChart As Object Dim oExcelShape As Object Set oExcelApp = CreateObject("Excel.Application") Set oExcelBook = oExcelApp.Workbooks.Add ' Comment out the following line and everything will work oExcelBook.Windows(1).Visible = False ' If SP1 for office 2003 is installed, this line fails with the following error ' Run-time error '-2147417851 (80010105)': Method 'Add' of object 'Sheets' failed Set oExcelChart = oExcelBook.Charts.Add ' If SP1 is not installed, this line fails with the following error ' "run-time error '1004': Application-defined or object-defined error" Set oExcelShape = oExcelChart.Shapes.AddLabel(msoOrientationHorizont al, 0, 0, 10, 10) oExcelShape.TextFrame.Characters.Text = "Hello" oExcelShape.Line.Visible = msoTrue oExcelShape.TextFrame.AutoSize = True oExcelBook.Close False oExcelApp.Quit Set oExcelShape = Nothing Set oExcelChart = Nothing Set oExcelBook = Nothing Set oExcelApp = Nothing Unload Me End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Problem with hiden workbooks
I've been able to recreate the problem on 3 different machines; XP SP1, XP
SP2 and server 2003 all running Office 2003 with and without SP1. I hide the workbook so the user can't access it and mess up my program. When I create the application object, it runs another excel.exe which is great. The problem is when a user double clicks on an excel file, it opens in my excel instance. This is a problem. Now my excel instance becomes visible along with my workbook. So, if I hide the workbook, they won't see it when they double click open their excel file. "Jim Rech" wrote: Your code ran fine for me with and without commenting out the line. I ran the code from Word since I don't have VB6 installed but that shouldn't make any difference. I'm not sure why you want to hide the window though since Excel itself is not visible so there's nothing to see in any case. -- Jim "Daniel Knueven" wrote in message ... I am using a hidden workbook to generate graphs using Excel. I was having a problem adding a label to the chart while the workbook was hidden. So, I installed SP1 for Office 2003 to see if that would fix the problem. Now, I can't even add a chart to the workbook when it is hidden. I am running on Windows XP SP2. I would appreciate any help. Included is code that can reproduce the problem: '----------------------------------------------------------------------- Option Explicit Private Const msoOrientationHorizontal As Long = 1 Private Const msoTrue As Long = -1 Private Sub Form_Load() Dim oExcelApp As Object Dim oExcelBook As Object Dim oExcelChart As Object Dim oExcelShape As Object Set oExcelApp = CreateObject("Excel.Application") Set oExcelBook = oExcelApp.Workbooks.Add ' Comment out the following line and everything will work oExcelBook.Windows(1).Visible = False ' If SP1 for office 2003 is installed, this line fails with the following error ' Run-time error '-2147417851 (80010105)': Method 'Add' of object 'Sheets' failed Set oExcelChart = oExcelBook.Charts.Add ' If SP1 is not installed, this line fails with the following error ' "run-time error '1004': Application-defined or object-defined error" Set oExcelShape = oExcelChart.Shapes.AddLabel(msoOrientationHorizont al, 0, 0, 10, 10) oExcelShape.TextFrame.Characters.Text = "Hello" oExcelShape.Line.Visible = msoTrue oExcelShape.TextFrame.AutoSize = True oExcelBook.Close False oExcelApp.Quit Set oExcelShape = Nothing Set oExcelChart = Nothing Set oExcelBook = Nothing Set oExcelApp = Nothing Unload Me End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
various printing from a hiden sheet | Excel Programming | |||
Why can't I unhide a hiden row | Excel Discussion (Misc queries) | |||
Is column hiden? | Excel Programming | |||
Is column hiden? | Excel Programming | |||
hiden sheet | Excel Programming |