Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Multiple Worksheet Selection

Something like this...

MsgBox ActiveWindow.SelectedSheets.Count
--
HTH...

Jim Thomlinson


"Peter-d" wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

Right on... I don't use the activewindow too often. I should have looked
harder.

Thanks Jim & Jim


"Jim Thomlinson" wrote:

Something like this...

MsgBox ActiveWindow.SelectedSheets.Count
--
HTH...

Jim Thomlinson


"Peter-d" wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Multiple Worksheet Selection

Sub HowMany()
Dim ThatMany As Long
ThatMany = ActiveWindow.SelectedSheets.Count
MsgBox ThatMany
End Sub

"Peter-d"

wrote in message
Is there a way out there to figure out from VB code if more than one
worksheet is selected?
Thanks
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

Just to expand a little...

I have created a workbook where I have trapped all printing and print
preview function. Different things happen for different sheets.
But it all goes wrong if the user has selected multiple sheets to print all
at once.

I tried using
ActiveSheet.Select Replace:= True
in the BeforePrint event of the workbook to try forcing the active sheet to
be the only one selected, but while this seems to work in the immediate
window, it seems to be ignore during the actual actual event.

My preference would be to determine that more than one sheet was selected
and give the user a proper warning message and cencelling the print event.

Any suggestions?

"Peter-d" wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

Nevermind this... Jim and Jim provided me with my solution.

"Peter-d" wrote:

Just to expand a little...

I have created a workbook where I have trapped all printing and print
preview function. Different things happen for different sheets.
But it all goes wrong if the user has selected multiple sheets to print all
at once.

I tried using
ActiveSheet.Select Replace:= True
in the BeforePrint event of the workbook to try forcing the active sheet to
be the only one selected, but while this seems to work in the immediate
window, it seems to be ignore during the actual actual event.

My preference would be to determine that more than one sheet was selected
and give the user a proper warning message and cencelling the print event.

Any suggestions?

"Peter-d" wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multiple Worksheet Selection

msgbox activewindow.selectedsheets.count

You can select different sheets in each window, though.

Peter-d wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks


--

Dave Peterson
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

Thanks Dave.

The ability to select different sheet in each window won't bother me. If you
look at my own reply, you will see that I just need to know before I print,
and since each window will handle their print selection individually, it
wan't matter.

But thatnks for the activewindow.selectedsheets tip.

"Dave Peterson" wrote:

msgbox activewindow.selectedsheets.count

You can select different sheets in each window, though.

Peter-d wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks


--

Dave Peterson

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multiple Worksheet Selection

I don't think you can ever know.

Inside the file|Print dialog, there's an option for "entire workbook".

I think the best you could do would be to disable the built in printing.

In the ThisWorkbook module.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Use the Buttons on each sheet!"
End Sub

Then provide the user with macros that print what you want.

Kind of...

Option explicit
sub testme()
'set up whatever you want
'turn off event handling, so your code can print
application.enableevents = false
'do your specific printing
'turn on events
application.enableevents = true
end sub


But all this fails if events are disabled--or macros are disabled.


Peter-d wrote:

Thanks Dave.

The ability to select different sheet in each window won't bother me. If you
look at my own reply, you will see that I just need to know before I print,
and since each window will handle their print selection individually, it
wan't matter.

But thatnks for the activewindow.selectedsheets tip.

"Dave Peterson" wrote:

msgbox activewindow.selectedsheets.count

You can select different sheets in each window, though.

Peter-d wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks


--

Dave Peterson


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

Well, yeha, I'm essentially doing something like this...e xcept I took it one
step further where I hooked my own code instead of the standard print
function. The only thing, and thanks for pointing it out, is that in using
this line:
Application.Dialogs(xlDialogPrint).Show
in my code to actually invoke the menu, I didn't look at all options
available to the user and didn't think og the "entire workbook" option.

I could just use the PrintOut method, but I liked giving the user the dialog
in case they wanted to change printer and other properties.

I'll have to give this some more thought.

Thanks

"Dave Peterson" wrote:

I don't think you can ever know.

Inside the file|Print dialog, there's an option for "entire workbook".

I think the best you could do would be to disable the built in printing.

In the ThisWorkbook module.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Use the Buttons on each sheet!"
End Sub

Then provide the user with macros that print what you want.

Kind of...

Option explicit
sub testme()
'set up whatever you want
'turn off event handling, so your code can print
application.enableevents = false
'do your specific printing
'turn on events
application.enableevents = true
end sub


But all this fails if events are disabled--or macros are disabled.


Peter-d wrote:

Thanks Dave.

The ability to select different sheet in each window won't bother me. If you
look at my own reply, you will see that I just need to know before I print,
and since each window will handle their print selection individually, it
wan't matter.

But thatnks for the activewindow.selectedsheets tip.

"Dave Peterson" wrote:

msgbox activewindow.selectedsheets.count

You can select different sheets in each window, though.

Peter-d wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks

--

Dave Peterson


--

Dave Peterson



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Multiple Worksheet Selection

In case anybody else is reading this and happens to care...

I ended up simply hiding all unactive sheets in my print function and
unhiding them when the print is complete. This way, I can still use the
dialog box and I don't care if they try to change the "Print What" to entire
workbook.


"Peter-d" wrote:

Well, yeha, I'm essentially doing something like this...e xcept I took it one
step further where I hooked my own code instead of the standard print
function. The only thing, and thanks for pointing it out, is that in using
this line:
Application.Dialogs(xlDialogPrint).Show
in my code to actually invoke the menu, I didn't look at all options
available to the user and didn't think og the "entire workbook" option.

I could just use the PrintOut method, but I liked giving the user the dialog
in case they wanted to change printer and other properties.

I'll have to give this some more thought.

Thanks

"Dave Peterson" wrote:

I don't think you can ever know.

Inside the file|Print dialog, there's an option for "entire workbook".

I think the best you could do would be to disable the built in printing.

In the ThisWorkbook module.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Use the Buttons on each sheet!"
End Sub

Then provide the user with macros that print what you want.

Kind of...

Option explicit
sub testme()
'set up whatever you want
'turn off event handling, so your code can print
application.enableevents = false
'do your specific printing
'turn on events
application.enableevents = true
end sub


But all this fails if events are disabled--or macros are disabled.


Peter-d wrote:

Thanks Dave.

The ability to select different sheet in each window won't bother me. If you
look at my own reply, you will see that I just need to know before I print,
and since each window will handle their print selection individually, it
wan't matter.

But thatnks for the activewindow.selectedsheets tip.

"Dave Peterson" wrote:

msgbox activewindow.selectedsheets.count

You can select different sheets in each window, though.

Peter-d wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks

--

Dave Peterson


--

Dave Peterson

  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Multiple Worksheet Selection

Maybe you could give them an abbreviated dialog:

Application.Dialogs(xlDialogPrinterSetup).Show



Peter-d wrote:

Well, yeha, I'm essentially doing something like this...e xcept I took it one
step further where I hooked my own code instead of the standard print
function. The only thing, and thanks for pointing it out, is that in using
this line:
Application.Dialogs(xlDialogPrint).Show
in my code to actually invoke the menu, I didn't look at all options
available to the user and didn't think og the "entire workbook" option.

I could just use the PrintOut method, but I liked giving the user the dialog
in case they wanted to change printer and other properties.

I'll have to give this some more thought.

Thanks

"Dave Peterson" wrote:

I don't think you can ever know.

Inside the file|Print dialog, there's an option for "entire workbook".

I think the best you could do would be to disable the built in printing.

In the ThisWorkbook module.

Option Explicit
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
MsgBox "Use the Buttons on each sheet!"
End Sub

Then provide the user with macros that print what you want.

Kind of...

Option explicit
sub testme()
'set up whatever you want
'turn off event handling, so your code can print
application.enableevents = false
'do your specific printing
'turn on events
application.enableevents = true
end sub


But all this fails if events are disabled--or macros are disabled.


Peter-d wrote:

Thanks Dave.

The ability to select different sheet in each window won't bother me. If you
look at my own reply, you will see that I just need to know before I print,
and since each window will handle their print selection individually, it
wan't matter.

But thatnks for the activewindow.selectedsheets tip.

"Dave Peterson" wrote:

msgbox activewindow.selectedsheets.count

You can select different sheets in each window, though.

Peter-d wrote:

Is there a way out there to figure out from VB code if more than one
worksheet is selected?

Thanks

--

Dave Peterson


--

Dave Peterson


--

Dave Peterson
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
Lock worksheet, based on dropdown selection prior worksheet Michele New Users to Excel 9 June 21st 09 10:31 PM
multiple selection AND Excel Discussion (Misc queries) 9 February 13th 09 07:40 PM
Multiple selection David Excel Programming 1 January 12th 06 05:43 AM
Multiple Col. Selection David Fixemer Excel Programming 6 February 17th 04 11:10 PM
multiple selection Michalll Excel Programming 3 December 3rd 03 12:58 AM


All times are GMT +1. The time now is 08:35 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"