View Single Post
 
Old 06-14-2012, 02:16 PM
Francisco Sousa Francisco Sousa is offline Windows 7 64bit Office 2003
Novice
 
Join Date: Jun 2012
Posts: 4
Francisco Sousa is on a distinguished road
Default Close Printpreview and load a Userform

He liked to close the PrintPreview reloading a userform, I can not stop the PrintPreview run the following code because the code runs showing the userform loads over PrintPreview, any help would be greatly appreciated
Code:
Private Sub cmdPrevisualizar_Click()
     
If Len(ActiveDocument.Bookmarks("nome").Range) = 2 And Len(ActiveDocument.Bookmarks("morada").Range) = 2 And Len(ActiveDocument.Bookmarks("localidade").Range) = 2 And _
    Len(ActiveDocument.Bookmarks("cpostal").Range) = 2 And Len(ActiveDocument.Bookmarks("designacao").Range) = 2 And Len(ActiveDocument.Bookmarks("licenca").Range) = 2 Then
    strlimpa = MsgBox("O ofício encontra-se vazio!", vbInformation + vbOKOnly, "Pré-visualizar")
    
    Call DesprotegeWord

    With ThisDocument.CommandButton1
        .Height = 24
        .Width = 72
    End With
     
    With ThisDocument.CommandButton11
        .Height = 24
        .Width = 72
    End With
    
    tbnome.SetFocus
    
    Exit Sub
Else
    
    Application.ScreenRefresh
    
    With ThisDocument.CommandButton1
        .Height = 1
        .Width = 1
    End With
     
    With ThisDocument.CommandButton11
        .Height = 1
        .Width = 1
    End With
    
    Me.Hide
    
    Call DesprotegeWord
    
    Selection.TypeText Text:=" "
    Selection.TypeBackspace
    
    ActiveDocument.printpreview

    Me.Show

    With ThisDocument.CommandButton1
        .Height = 24
        .Width = 72
    End With
     
    With ThisDocument.CommandButton11
        .Height = 24
        .Width = 72
    End With

    With ThisDocument.CommandButton1
        .Height = 24
        .Width = 72
    End With

End If

End Sub
Reply With Quote