Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default return to xlnormalview problem

hi,office developers.

i have this macro just for test.
but not return to xlnormalview on the copied sheet.
i'd very appreciated for any comments what the problem with below macro.
thanks in advance.

Sub Macro1()
Dim ViewMode As Long
ActiveSheet.Select
Range("A1") = 1
Range("D20") = 1
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.Copy AFTER:=ActiveSheet
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
End With
ActiveWindow.View = ViewMode
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,549
Default return to xlnormalview problem

Several comments...
1. The active sheet is the selected sheet; so you don't need Select.
2. The ViewMode line is in the wrong place.
It should be immediately after the Range("D20") line.
3. You can step thru the revised code using the F8 key and the
window will return to Normal view. However, if you just
run the code normally - F5 key - then the window does not
return to Normal view. It will work if you introduce a pause
before attempting to reset the view (but that's another story)...
'--
Sub Macro1()
Dim ViewMode As Long
Range("A1") = 1
Range("D20") = 1
ViewMode = ActiveWindow.View
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.Copy AFTER:=ActiveSheet
'pause needed here
ActiveWindow.View = ViewMode
End Sub
--
Jim Cone
Portland, Oregon USA



"mrLee"

wrote in message
hi,office developers.

i have this macro just for test.
but not return to xlnormalview on the copied sheet.
i'd very appreciated for any comments what the problem with below macro.
thanks in advance.

Sub Macro1()
Dim ViewMode As Long
ActiveSheet.Select
Range("A1") = 1
Range("D20") = 1
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.Copy AFTER:=ActiveSheet
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
End With
ActiveWindow.View = ViewMode
End Sub
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default return to xlnormalview problem

The code that you posted is operating properly as written. The variable
ViewMode is set to the pagebreak view which displays with the shaded area.
Then the xlNormalView is returned for the active sheet, which is the new
added sheet. To return the original ActiveSheet to the xlNormalView, Try
this:


Sub Macro1()
Dim ViewMode As Long
ActiveSheet.Select
shNm = ActiveSheet.Name
Range("A1") = 1
Range("D20") = 1
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.Copy AFTER:=ActiveSheet
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
End With
Sheets(shNm).Activate
ActiveWindow.View = xlNormalView
End Sub






"mrLee" wrote:

hi,office developers.

i have this macro just for test.
but not return to xlnormalview on the copied sheet.
i'd very appreciated for any comments what the problem with below macro.
thanks in advance.

Sub Macro1()
Dim ViewMode As Long
ActiveSheet.Select
Range("A1") = 1
Range("D20") = 1
ActiveWindow.View = xlPageBreakPreview
ActiveSheet.Copy AFTER:=ActiveSheet
With ActiveSheet
.Select
ViewMode = ActiveWindow.View
ActiveWindow.View = xlNormalView
End With
ActiveWindow.View = ViewMode
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
Carriage Return Problem Don L[_2_] Excel Discussion (Misc queries) 1 March 12th 10 07:04 PM
problem calculating rate of return ties[_2_] Excel Programming 2 September 17th 04 03:10 PM
Problem with UDF can't return the value of a formula Billy[_4_] Excel Programming 4 August 28th 04 12:08 AM
Problem with message box return value John Baker Excel Programming 3 July 2nd 04 08:53 PM
Function Problem.... Return Value Schrades Excel Programming 3 November 12th 03 08:33 PM


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