469,088 Members | 1,274 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,088 developers. It's quick & easy.

Using Excel Objects

I've written an application for reading information from a spreadsheet and
allowing the user to add and update information in the spreadsheet.

One spreadsheet I accessed in this fashion is now unreadable and get an
application error when I open it. I also can't delete it. I'm assuming
that I didn't properly close it down once. Is there any way I can correct
the problem

I finally got the application working OK. My remaining problem is that when
I open the workbook, the worksheets are hidden. How do I release the
spreadsheet in such a fashion that the worksheets are visible immediately
when I open the workbook?

David Gerstman
Jul 17 '05 #1
6 6341
OK, there's more than one question here, so here goes:

1) With the unreadable/not being able to delete - try looking for Excel in
the task manager after your program has closed. If it is, then do the
following to make sure that it's shut down in future:

ExcelApp.Quit
set excelapp = nothing

Of course depending on how you got the object "Excel.Application" might mean
that if Excel is open on the screen, it will close it down. There are loads
of issues with having Excel open and automating it in VB at the same time,
too many to list here, just have a play until you get what you want. I
always recommend setting the Excel object to nothing though, even if you
decide not to Quit it first.

2) Worksheets being hidden? Hmmm... I've never seen this, and for now I'd
assume it's a side-effect of issue #1 above. You can control whether tabs
are visible or hidden, of course (set the Sheet.Visible property to one of
the "Excel.XlSheetVisibility" constants as defined in the object browser.
If this ain't it - give us a shout an' we'll have another go.

Hope this helps.

Sparky.

"David Gerstman" <dh********@yahoo.com> wrote in message
news:Hr********@arl.army.mil...
I've written an application for reading information from a spreadsheet and
allowing the user to add and update information in the spreadsheet.

One spreadsheet I accessed in this fashion is now unreadable and get an
application error when I open it. I also can't delete it. I'm assuming
that I didn't properly close it down once. Is there any way I can correct
the problem

I finally got the application working OK. My remaining problem is that when I open the workbook, the worksheets are hidden. How do I release the
spreadsheet in such a fashion that the worksheets are visible immediately
when I open the workbook?

David Gerstman

Jul 17 '05 #2
David,
Excel generates a temp file when you open any workbook. If the WB is not
properly closed, the temp file remains. attempting to reopen the WB will
cause an error. Restarting Excel usually deletes this temp file and you're
fine. Or delete the temp file, if you can find it; in the same directory as
the WB, unless it's from the network, then...
If this does not work, then may the WB file is corrupt and can't be opened
any way.

The .Hidden/Visible property can applies to many objects; Excel, WB,
worksheet, window. Which are you having to reset ?
Are you saving the WB after you change the visibility ?

NickHK

"Sparky" <ne**********@hotmail.com> wrote in message
news:bu**********@news8.svr.pol.co.uk...
| OK, there's more than one question here, so here goes:
|
| 1) With the unreadable/not being able to delete - try looking for Excel
in
| the task manager after your program has closed. If it is, then do the
| following to make sure that it's shut down in future:
|
| ExcelApp.Quit
| set excelapp = nothing
|
| Of course depending on how you got the object "Excel.Application" might
mean
| that if Excel is open on the screen, it will close it down. There are
loads
| of issues with having Excel open and automating it in VB at the same time,
| too many to list here, just have a play until you get what you want. I
| always recommend setting the Excel object to nothing though, even if you
| decide not to Quit it first.
|
| 2) Worksheets being hidden? Hmmm... I've never seen this, and for now
I'd
| assume it's a side-effect of issue #1 above. You can control whether tabs
| are visible or hidden, of course (set the Sheet.Visible property to one of
| the "Excel.XlSheetVisibility" constants as defined in the object browser.
| If this ain't it - give us a shout an' we'll have another go.
|
| Hope this helps.
|
| Sparky.
|
| "David Gerstman" <dh********@yahoo.com> wrote in message
| news:Hr********@arl.army.mil...
| > I've written an application for reading information from a spreadsheet
and
| > allowing the user to add and update information in the spreadsheet.
| >
| > One spreadsheet I accessed in this fashion is now unreadable and get an
| > application error when I open it. I also can't delete it. I'm assuming
| > that I didn't properly close it down once. Is there any way I can
correct
| > the problem
| >
| > I finally got the application working OK. My remaining problem is that
| when
| > I open the workbook, the worksheets are hidden. How do I release the
| > spreadsheet in such a fashion that the worksheets are visible
immediately
| > when I open the workbook?
| >
| > David Gerstman
| >
| >
|
|
Jul 17 '05 #3
Sparky, I really appreciate your help.

I have done the ExcelApp.quit and set it to "nothing"

I have those in the Form_Unload sub. Do they belong someplace else? (When I
stop in middle of debugging, does Form_Unload execute? I think so.)

I also assume that the hidden spreadsheet is a function of not shutting down
correctly. I'll probably try the visibility stuff.

Thank you VERY much.

David

"Sparky" <ne**********@hotmail.com> wrote in message
news:bu**********@news8.svr.pol.co.uk...
OK, there's more than one question here, so here goes:

1) With the unreadable/not being able to delete - try looking for Excel in the task manager after your program has closed. If it is, then do the
following to make sure that it's shut down in future:

ExcelApp.Quit
set excelapp = nothing

Of course depending on how you got the object "Excel.Application" might mean that if Excel is open on the screen, it will close it down. There are loads of issues with having Excel open and automating it in VB at the same time,
too many to list here, just have a play until you get what you want. I
always recommend setting the Excel object to nothing though, even if you
decide not to Quit it first.

2) Worksheets being hidden? Hmmm... I've never seen this, and for now I'd assume it's a side-effect of issue #1 above. You can control whether tabs
are visible or hidden, of course (set the Sheet.Visible property to one of
the "Excel.XlSheetVisibility" constants as defined in the object browser.
If this ain't it - give us a shout an' we'll have another go.

Hope this helps.

Sparky.

"David Gerstman" <dh********@yahoo.com> wrote in message
news:Hr********@arl.army.mil...
I've written an application for reading information from a spreadsheet and allowing the user to add and update information in the spreadsheet.

One spreadsheet I accessed in this fashion is now unreadable and get an
application error when I open it. I also can't delete it. I'm assuming
that I didn't properly close it down once. Is there any way I can correct the problem

I finally got the application working OK. My remaining problem is that

when
I open the workbook, the worksheets are hidden. How do I release the
spreadsheet in such a fashion that the worksheets are visible immediately when I open the workbook?

David Gerstman


Jul 17 '05 #4
Nick
I never wrote anything to affect visibility.
However, I'll add a line.
I really appreciate your pointer here. It explains some of the problems I'm
having. I think.
I'm going to look for the temp file.
Again thank you so much!
David

"Nick HK" <Ni****@TungCheeWah.Invalid> wrote in message
news:bu**********@imsp212.netvigator.com...
David,
Excel generates a temp file when you open any workbook. If the WB is not
properly closed, the temp file remains. attempting to reopen the WB will
cause an error. Restarting Excel usually deletes this temp file and you're
fine. Or delete the temp file, if you can find it; in the same directory as the WB, unless it's from the network, then...
If this does not work, then may the WB file is corrupt and can't be opened
any way.

The .Hidden/Visible property can applies to many objects; Excel, WB,
worksheet, window. Which are you having to reset ?
Are you saving the WB after you change the visibility ?

NickHK

"Sparky" <ne**********@hotmail.com> wrote in message
news:bu**********@news8.svr.pol.co.uk...
| OK, there's more than one question here, so here goes:
|
| 1) With the unreadable/not being able to delete - try looking for Excel
in
| the task manager after your program has closed. If it is, then do the
| following to make sure that it's shut down in future:
|
| ExcelApp.Quit
| set excelapp = nothing
|
| Of course depending on how you got the object "Excel.Application" might
mean
| that if Excel is open on the screen, it will close it down. There are
loads
| of issues with having Excel open and automating it in VB at the same time, | too many to list here, just have a play until you get what you want. I
| always recommend setting the Excel object to nothing though, even if you
| decide not to Quit it first.
|
| 2) Worksheets being hidden? Hmmm... I've never seen this, and for now
I'd
| assume it's a side-effect of issue #1 above. You can control whether tabs | are visible or hidden, of course (set the Sheet.Visible property to one of | the "Excel.XlSheetVisibility" constants as defined in the object browser. | If this ain't it - give us a shout an' we'll have another go.
|
| Hope this helps.
|
| Sparky.
|
| "David Gerstman" <dh********@yahoo.com> wrote in message
| news:Hr********@arl.army.mil...
| > I've written an application for reading information from a spreadsheet
and
| > allowing the user to add and update information in the spreadsheet.
| >
| > One spreadsheet I accessed in this fashion is now unreadable and get an | > application error when I open it. I also can't delete it. I'm assuming | > that I didn't properly close it down once. Is there any way I can
correct
| > the problem
| >
| > I finally got the application working OK. My remaining problem is that | when
| > I open the workbook, the worksheets are hidden. How do I release the
| > spreadsheet in such a fashion that the worksheets are visible
immediately
| > when I open the workbook?
| >
| > David Gerstman
| >
| >
|
|

Jul 17 '05 #5
"David Gerstman" <dh********@yahoo.com> wrote in message
news:Hr********@arl.army.mil...
Sparky, I really appreciate your help.

I have done the ExcelApp.quit and set it to "nothing"

I have those in the Form_Unload sub. Do they belong someplace else? (When I stop in middle of debugging, does Form_Unload execute? I think so.)


If you by that mean pressing the "Stop" button in the IDE, the andwer is NO!

That is the same as using End. Your program stops abruptly, without any form
of cleanup

--
Dag.
Jul 17 '05 #6
I've a good mind to write a program that enums the processes, and those it
can't find an hwnd for and that are excel, it kills. I'd have it running as
a service.

"Sparky" <ne**********@hotmail.com> wrote in message
news:bu**********@news8.svr.pol.co.uk...
OK, there's more than one question here, so here goes:

1) With the unreadable/not being able to delete - try looking for Excel in the task manager after your program has closed. If it is, then do the
following to make sure that it's shut down in future:

ExcelApp.Quit
set excelapp = nothing

Of course depending on how you got the object "Excel.Application" might mean that if Excel is open on the screen, it will close it down. There are loads of issues with having Excel open and automating it in VB at the same time,
too many to list here, just have a play until you get what you want. I
always recommend setting the Excel object to nothing though, even if you
decide not to Quit it first.

2) Worksheets being hidden? Hmmm... I've never seen this, and for now I'd assume it's a side-effect of issue #1 above. You can control whether tabs
are visible or hidden, of course (set the Sheet.Visible property to one of
the "Excel.XlSheetVisibility" constants as defined in the object browser.
If this ain't it - give us a shout an' we'll have another go.

Hope this helps.

Sparky.

"David Gerstman" <dh********@yahoo.com> wrote in message
news:Hr********@arl.army.mil...
I've written an application for reading information from a spreadsheet and allowing the user to add and update information in the spreadsheet.

One spreadsheet I accessed in this fashion is now unreadable and get an
application error when I open it. I also can't delete it. I'm assuming
that I didn't properly close it down once. Is there any way I can correct the problem

I finally got the application working OK. My remaining problem is that

when
I open the workbook, the worksheets are hidden. How do I release the
spreadsheet in such a fashion that the worksheets are visible immediately when I open the workbook?

David Gerstman


Jul 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by dave | last post: by
9 posts views Thread by Doug Glancy | last post: by
7 posts views Thread by =?Utf-8?B?VGVycnkgSG9sbGFuZA==?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by kglaser89 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.