Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
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
  #2  
Old 06-15-2012, 06:27 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,296
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Why are you switching to Print Preview before loading your form? You have:
ActiveDocument.PrintPreview
Me.Show
If you don't want Print Preview when you load your form then delete this line:
ActiveDocument.PrintPreview
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 06-16-2012, 04:07 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 ActiveDocument.PrintPreview - Francisco Sousa

Hello

Sorry, I think I put the problem was badly formulated, the problem is that the ActiveDocument.PrintPreview is triggered by a button on a userform in Word and userform is hidden (Me.Hide), but when this runs ActiveDocument.PrintPreview loads the userform (Me.Show) ActiveDocument.PrintPreview immediately on the screen and not on the screen of the Word as it should be, that because there is no break in ActiveDocument.PrintPreview when it fired. Dear Mr. Macropod can send you the file for your analysis, would be very grateful.
I apologize for my poor english


Sincerely
Best Regards,
Reply With Quote
  #4  
Old 06-16-2012, 04:27 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,296
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Francisco,

You can attach a document to a post - use the paperclip symbol on the Advanced screen
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 06-17-2012, 03:38 AM
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 ActiveDocument.PrintPreview - Francisco Sousa

Hi Paul,

I attach the document as you said on the paperclip symbol, and the name of the Word document is WORD FORM - Francisco Sousa.doc

Cheers,
Francisco Sousa
Attached Files
File Type: doc WORD FORM - Francisco Sousa.doc (252.5 KB, 12 views)
Reply With Quote
  #6  
Old 06-17-2012, 09:26 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,296
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Francisco,

I am unable to resolve this problem - I keep getting errors because your document has many undeclared variables and it only seems to partly work if it is changed to a template. Even then, I keep getting errors, not only for the print preview.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 06-19-2012, 12:31 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 16,296
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Hi Francisco,

Just to prove that you can do print preview from a userform, see attached.
Attached Files
File Type: doc Lorem ipsum.doc (43.5 KB, 19 views)
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #8  
Old 07-07-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 - Solved

Hi Paul,

Thanks for answering me, you solved my problem. Sorry for the delay on answering back.

Sincerely
Best Regards,

Francisco Sousa
Reply With Quote
Reply
Please reply to this thread with any new information or opinions.

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
showing a userform after hiding jillapass Word VBA 0 05-31-2012 06:13 AM
Outlook userform validation help aiwnjoo Outlook 0 12-08-2010 12:57 AM
PowerPoint Add-in fails to load in start up but loads successfully if load manually f shahbazlibra PowerPoint 0 11-30-2010 08:36 AM
Displaying data from spreadsheet in Userform darklide Excel 0 03-12-2010 05:42 AM
[Word 2003] Macro's and a UserForm xanuex Word 0 10-19-2009 05:42 AM


All times are GMT -7. The time now is 03:24 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft