View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
keiji kounoike keiji kounoike is offline
external usenet poster
 
Posts: 199
Default How to Write Error Trap

How can you have a workbook with no sheet open?
Does the code below ever stop by error?

Keiji

GavinS wrote:
I have the following code to toggle between print preview and normal
view but I need to add an error statement just in case there is no
sheet open.

Can someone please suggest how I might write this.

Thanks

Sub TogglePrintView()

If ActiveWindow.View = xlPageBreakPreview Then
ActiveWindow.View = xlNormalView
ElseIf ActiveWindow.View = xlNormalView Then
ActiveWindow.View = xlPageBreakPreview
End If
End Sub