Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Close Hidden Data Sheet

I have a workbook that uses a hidden workbook for data. For the most part,
everything works, but there is one minor glitch.

For closing, I use:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("HRData.xls").Close False
End Sub

When the user closes the workbook, the dialog box to save comes up with YES,
NO, CANCEL. If the user hits CANCEL, the HRData.xls is already closed and
the user no longer has access to the data. Is there a better way to close
the hidden workbook?

thank you,
--
Jeff
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Close Hidden Data Sheet

Try:
Application.DisplayAlerts = False

Swisse
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Close Hidden Data Sheet

Use the workbook_SelectionChange event. Have it check if the data workbook
is open. If not, open it.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a workbook that uses a hidden workbook for data. For the most

part,
everything works, but there is one minor glitch.

For closing, I use:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("HRData.xls").Close False
End Sub

When the user closes the workbook, the dialog box to save comes up with

YES,
NO, CANCEL. If the user hits CANCEL, the HRData.xls is already closed and
the user no longer has access to the data. Is there a better way to close
the hidden workbook?

thank you,
--
Jeff



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 184
Default Close Hidden Data Sheet

Hi,
I agree with swisse, and would add that in general it is a good idea to
set display alerts back to true:

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.DisplayAlerts = False
Workbooks("HRData.xls").Close False
Application.DisplayAlerts = True
End Sub

Regards, Lonnie M.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 13
Default Close Hidden Data Sheet

Rightly said Lonnie.

Swisse


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 921
Default Close Hidden Data Sheet

Tom,
Can you possibly expand on that? I am not familiar with that event. Thank
you,
Jeff

"Tom Ogilvy" wrote:

Use the workbook_SelectionChange event. Have it check if the data workbook
is open. If not, open it.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a workbook that uses a hidden workbook for data. For the most

part,
everything works, but there is one minor glitch.

For closing, I use:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("HRData.xls").Close False
End Sub

When the user closes the workbook, the dialog box to save comes up with

YES,
NO, CANCEL. If the user hits CANCEL, the HRData.xls is already closed and
the user no longer has access to the data. Is there a better way to close
the hidden workbook?

thank you,
--
Jeff




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Close Hidden Data Sheet

Just for clarification, I assumed you didn't want to prevent the user from
seeing this dialog. If you want to prevent the user seeing the dialog, see
the answers from Swisse and Lonnie M.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Use the workbook_SelectionChange event. Have it check if the data

workbook
is open. If not, open it.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a workbook that uses a hidden workbook for data. For the most

part,
everything works, but there is one minor glitch.

For closing, I use:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("HRData.xls").Close False
End Sub

When the user closes the workbook, the dialog box to save comes up with

YES,
NO, CANCEL. If the user hits CANCEL, the HRData.xls is already closed

and
the user no longer has access to the data. Is there a better way to

close
the hidden workbook?

thank you,
--
Jeff





  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Close Hidden Data Sheet

If you are using the workbook_beforeclose event, then go to that module and
in the right dropdown select SheetSelectionChange

This assumes you don't want to suppress the prompt.

this event will fire everytime the user selects a different cell. You could
check it your data workbook is open and then open it.

Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target
As Excel.Range)
Dim bk as Workbook
On Error Resume Next
set bk = Workbooks("HRData.xls")
On Error goto 0
if bk is nothing then
Workbooks.Open thisworkbook.Path & "\HRData.xls"
End if
End Sub

See Chip Pearson's page on Events if you weren't just confused because I
said Workbook Level SelectionChange rather Workbook Level
SheetSelectionChange.

http://www.cpearson.com/Excel/events.htm

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
Tom,
Can you possibly expand on that? I am not familiar with that event.

Thank
you,
Jeff

"Tom Ogilvy" wrote:

Use the workbook_SelectionChange event. Have it check if the data

workbook
is open. If not, open it.

--
Regards,
Tom Ogilvy


"Jeff" wrote in message
...
I have a workbook that uses a hidden workbook for data. For the most

part,
everything works, but there is one minor glitch.

For closing, I use:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Workbooks("HRData.xls").Close False
End Sub

When the user closes the workbook, the dialog box to save comes up

with
YES,
NO, CANCEL. If the user hits CANCEL, the HRData.xls is already closed

and
the user no longer has access to the data. Is there a better way to

close
the hidden workbook?

thank you,
--
Jeff






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
copy hidden sheet data Atiq Excel Discussion (Misc queries) 2 January 27th 10 08:41 PM
reading data from hidden sheet Atiq Excel Discussion (Misc queries) 4 January 27th 10 08:14 PM
How to paste data over the hidden rows in a sheet with a filter hezemeftez Excel Discussion (Misc queries) 2 August 2nd 06 03:29 PM
I need my Hidden Rows to stay hidden when I print the sheet. Rosaliewoo Excel Discussion (Misc queries) 2 July 20th 06 07:51 PM
Saving hidden data with a worksheet (preferably without using a hidden sheet) Dick Kusleika[_3_] Excel Programming 2 January 21st 04 04:39 PM


All times are GMT +1. The time now is 05:13 PM.

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

About Us

"It's about Microsoft Excel"