Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how to make macro work even a sheet is hidden.

hello there
I have macro assigned to a button in Sheet 1 which goes to sheet 2.
Press a button to Refresh and then PRINT preview

It does work in normal state.
I do not want the user to see the Sheet 2. I hid sheets from
Format-sheet-hide.
but the macro is not working when sheet 2 is hidden.
how to overcome this error
"can't execute code in break mode"

the macro code is

Sub Print_Preview()

Sheets("PaySlips2009-10").Select
Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows"
ActiveWindow.SelectedSheets.PrintPreview
End Sub



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default how to make macro work even a sheet is hidden.

You need NOT select. Don't know about the macro you are calling but I
suspect you also need NOT select.

Sub printhiddensheet()
Application.ScreenUpdating = False
With Sheets("sheet10")
.Visible = True
.PrintPreview
.Visible = False
End With
Application.ScreenUpdating = True
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"EagerGit" wrote in message
...
hello there
I have macro assigned to a button in Sheet 1 which goes to sheet 2.
Press a button to Refresh and then PRINT preview

It does work in normal state.
I do not want the user to see the Sheet 2. I hid sheets from
Format-sheet-hide.
but the macro is not working when sheet 2 is hidden.
how to overcome this error
"can't execute code in break mode"

the macro code is

Sub Print_Preview()

Sheets("PaySlips2009-10").Select
Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows"
ActiveWindow.SelectedSheets.PrintPreview
End Sub




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default how to make macro work even a sheet is hidden.

Try this:


Sub Print_Preview()

Sheets("PaySlips2009-10").Visible = True
Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows"
ActiveWindow.SelectedSheets.PrintPreview
Sheets("PaySlips2009-10").Visible = False
End Sub







"EagerGit" wrote in message
...
hello there
I have macro assigned to a button in Sheet 1 which goes to sheet 2.
Press a button to Refresh and then PRINT preview

It does work in normal state.
I do not want the user to see the Sheet 2. I hid sheets from
Format-sheet-hide.
but the macro is not working when sheet 2 is hidden.
how to overcome this error
"can't execute code in break mode"

the macro code is

Sub Print_Preview()

Sheets("PaySlips2009-10").Select
Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows"
ActiveWindow.SelectedSheets.PrintPreview
End Sub





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default how to make macro work even a sheet is hidden.

thank you both.
I have merged both of yours code togather and it is working.
I have to insert the .select as it was not giving preview of the payslips
but of the ACTIVe sheet where the button is.

final working code

Sub Print_Preview()
Application.ScreenUpdating = False
Sheets("PaySlips2009-10").Visible = True
Sheets("PaySlips2009-10").Select
Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows"
ActiveWindow.SelectedSheets.PrintPreview
Sheets("PaySlips2009-10").Visible = False
Application.ScreenUpdating = True
End Sub



"EagerGit" wrote in message
...
hello there
I have macro assigned to a button in Sheet 1 which goes to sheet 2.
Press a button to Refresh and then PRINT preview

It does work in normal state.
I do not want the user to see the Sheet 2. I hid sheets from
Format-sheet-hide.
but the macro is not working when sheet 2 is hidden.
how to overcome this error
"can't execute code in break mode"

the macro code is

Sub Print_Preview()

Sheets("PaySlips2009-10").Select
Application.Run "'Latest 2009Payslip.xls'!Sheet2.HURows"
ActiveWindow.SelectedSheets.PrintPreview
End Sub



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
HOW TO MAKE A LIST OF WORK SHEET IN WORK BOOK IN EXCEL 2007 goutam Excel Programming 1 February 1st 08 07:40 AM
How to make userform work publically with hidden sheets? Zigball Excel Discussion (Misc queries) 7 October 25th 06 03:30 PM
How to make userform work publically with hidden sheets? Zigball Excel Worksheet Functions 7 October 25th 06 03:30 PM
How to make userform work publically with hidden sheets? Zigball Excel Programming 7 October 25th 06 03:30 PM
Spin button in a work sheet - how do I make it work? [email protected] Excel Worksheet Functions 1 April 7th 05 08:43 PM


All times are GMT +1. The time now is 12:19 PM.

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

About Us

"It's about Microsoft Excel"