Hourglass appears when using "activeworkbook.Close Fal

jmichaelp

Board Regular
Joined
Aug 18, 2003
Messages
98
Hi, I have code that opens up a new temp workbook to which I add code (using John Walkenbach's method) to allow me to close the newly opened workbook without saving as follows:

Code:
 Set VBCodeMod = ActiveWorkbook.VBProject.VBComponents("ThisWorkbook").CodeModule
With VBCodeMod
StartLine = .CountOfLines + 1
.InsertLines StartLine, _
"Private Sub Workbook_BeforeClose(Cancel As Boolean)" & Chr(13) & _
"activeworkbook.Close  False" & Chr(13) & _
"End Sub"

When I close this workbook, the hourglass appears (in place of the pointer)& stays as long as the hourglass/pointer remains on the spreadsheet. When I move the hourglass/pointer off the screen, the hourglass goes away & I have the pointer again.

Does Excel think some process is still running? If so, why & how to I stop this?

Thanks!
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Re: Hourglass appears when using "activeworkbook.Close

Hmm, not quite sure how to do what you're asking and I'm not quite sure what you're doing in general, but, this may be of interest to you.

If you want to close a workbook and don't want the Save msg to appear, then:

Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
ThisWorkbook.Saved = True
End Sub
If I'm way off then disregard.
 
Upvote 0
tbardoni, worked perfectly without the hourglass thanks!

I always thought that "activeworkbook.Close False" was the standard way to cose without saving.

fyi, what I'm doing is opening a new, temp workbook with the results of a advanced filter. I have a multi-thousand row sheet with product data sorted according to price & sometimes I want to see all of a particular product only. So, I double-click on the product name & pop this up. I needed a popup workbook instead of a userform because I have a bunch of code behind the sheet that executes to provide additional information when I right-click on particular cells.
 
Upvote 0
Re: Hourglass appears when using "activeworkbook.Close

Beaware that people can still save the file. The code I posted only prevents the save msg from appearing. To keep people from saving as well, then:

Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Cancel = True
End Sub

edit: Ah, i saw the rest of your post above.
 
Upvote 0

Forum statistics

Threads
1,203,462
Messages
6,055,562
Members
444,799
Latest member
CraigCrowhurst

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top