Results 1 to 10 of 10

Print preview for excel 2007 not working

This is a discussion on Print preview for excel 2007 not working within the Excel Questions forums, part of the Question Forums category; Hi I am using following code on a command button for print preview and print command (in Excel 2003). That ...

  1. #1
    Board Regular
    Join Date
    Jun 2010
    Posts
    149

    Default Print preview for excel 2007 not working

    Hi I am using following code on a command button for print preview and print command (in Excel 2003). That is working perfectly in excel 2003. But this is not working in excel 2007.
    Code:
    'command button to print site survey 
    Private Sub cmdPrintSiteSurvey_Click()
    On Error GoTo ErrorLine
    Application.ScreenUpdating = False
    Dim SiteSurveyEnegy As VbMsgBoxResult
    ' message box to prompt print out
    SiteSurveyEnegy = MsgBox("Do you want to take print out of Site Survey Energy Sheet", vbYesNo + vbQuestion, "Print Out")
    
    If SiteSurveyEnegy = vbYes Then
    
        With Worksheets("3.0 Site Survey Energy Print")
            .Visible = True
            .PageSetup.PrintArea = "$A$1:$J$38"
            .PrintPreview
            .Visible = False
        End With
        
    End If
    Application.ScreenUpdating = True
    Exit Sub
    ErrorLine:
    MsgBox ("Error Number:" & Err.Number & ". " & Err.Description & ". Source:" & Err.Source)
    ActiveWorkbook.Close
    End Sub

  2. #2
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    69,460

    Default Re: Print preview for excel 2007 not working

    In what way isn't it working? Do you get an error? If so what is it?
    Microsoft MVP - Excel

  3. #3
    VoG
    VoG is offline
    MrExcel MVP
    Moderator
    VoG's Avatar
    Join Date
    Jun 2002
    Location
    127.0.0.1
    Posts
    63,514

    Default Re: Print preview for excel 2007 not working

    Try removing

    Code:
    Application.ScreenUpdating = False
    HTH, Peter
    Please test any code on a copy of your workbook.

  4. #4
    Board Regular
    Join Date
    Jun 2010
    Posts
    149

    Default Re: Print preview for excel 2007 not working

    in excel 2003 that is working perfectly. But in excel 2007 The print preview is there but there is no option for print. I can not use anything other than closing excel. Everything seems read only.

  5. #5
    MrExcel MVP
    Moderator
    Peter_SSs's Avatar
    Join Date
    May 2005
    Location
    Macksville, Australia
    Posts
    26,416

    Default Re: Print preview for excel 2007 not working

    Code works 'as is' for me in Excel 2007.
    Hope this helps, good luck.
    Peter

    - Read: Posting Guidelines, Forum Rules & FAQs
    - Want to post a small screen shot? Try one of these Excel jeanie, MrExcel HTML Maker or Borders-Copy-Paste (To test: Test Here)
    - If posting vba code, please use Code Tags - like this [code]Paste code here[/code] - or use the VBHTML Maker

  6. #6
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    69,460

    Default Re: Print preview for excel 2007 not working

    Quote Originally Posted by ManvinderKaur View Post
    in excel 2003 that is working perfectly. But in excel 2007 The print preview is there but there is no option for print. I can not use anything other than closing excel. Everything seems read only.
    Don't you see the ribbon as shown here?

    http://www.msoffice-tutorial-trainin...t-preview.html
    Microsoft MVP - Excel

  7. #7
    Board Regular
    Join Date
    Jun 2010
    Posts
    149

    Default Re: Print preview for excel 2007 not working

    no same normal ribbon as on other sheets. But not this ribben and all ribben becomes read only . but preview is there but ribben is not there...

  8. #8
    Board Regular
    Join Date
    Jun 2010
    Posts
    149

    Default Re: Print preview for excel 2007 not working

    I have removed this
    'Application.ScreenUpdating = True
    Now working
    thanks everyone

  9. #9
    MrExcel MVP
    Moderator
    Andrew Poulsom's Avatar
    Join Date
    Jul 2002
    Posts
    69,460

    Default Re: Print preview for excel 2007 not working

    Don't you even see the ribbon's tab, although it's not brought to the front?
    Microsoft MVP - Excel

  10. #10
    Board Regular
    Join Date
    Jun 2010
    Posts
    149

    Default Re: Print preview for excel 2007 not working

    I have used following code now perfect
    Code:
    'command button to print site survey 
    Private Sub cmdPrintSiteSurvey_Click()
    On Error GoTo ErrorLine
    'Application.ScreenUpdating = False
    Dim SiteSurveyEnegy As VbMsgBoxResult
    ' message box to prompt print out
    SiteSurveyEnegy = MsgBox("Do you want to take print out of Site Survey Energy Sheet", vbYesNo + vbQuestion, "Print Out")
    
    If SiteSurveyEnegy = vbYes Then
    
        With Worksheets("3.0 Site Survey Energy Print")
            .Visible = True
            .PageSetup.PrintArea = "$A$1:$J$38"
            .PrintPreview
            .Visible = False
        End With
        
    End If
    'Application.ScreenUpdating = True
    Exit Sub
    ErrorLine:
    MsgBox ("Error Number:" & Err.Number & ". " & Err.Description & ". Source:" & Err.Source)
    ActiveWorkbook.Close
    End Sub

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


DMCA.com