Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

word template flickering

Posted on 2008-10-09
3
Medium Priority
?
279 Views
Last Modified: 2012-05-05
In my word template I have several command buttons one of them is print button.
When I press this print button I first validate entries then hide buttons then print out document then unhide button.
This work fine but when I press button document is flickering and flashing for several seconds. This is disturbing and annoying.

How to eliminate this flickering?
Here is my code in print button click event.
 
Private Sub cmdPrint_Click()

'First we validate entries
Dim EntriesComplete As Boolean
EntriesComplete = False
'Call validate procedure ValidateServiceEntries
EntriesComplete = ValidateServiceEntries

 Dim ilsh As InlineShape

If EntriesComplete = True Then
    For Each ilsh In ActiveDocument.InlineShapes
    If ilsh.Type = wdInlineShapeOLEControlObject Then
        Select Case ilsh.OLEFormat.Object.Name
           
        Case "cmdPrint", "cmdSandEmail", "cmdSalesmanInfo", "cmdEditCustomer", _
        "cmdEditCustomer", "cmdEditContractor", "cmdComment", "cmdSave", _
        "lblEmailWarning", "cmdClearAndStartNew"
        ilsh.Range.Font.Hidden = True
        End Select
    End If
   
        Next ilsh
 print document without cm buttons
    ActiveDocument.PrintOut

put buttons back
    For Each ilsh In ActiveDocument.InlineShapes
   
    If ilsh.Type = wdInlineShapeOLEControlObject Then
        Select Case ilsh.OLEFormat.Object.Name
        Case "cmdPrint", "cmdSandEmail", "cmdSalesmanInfo", "cmdEditCustomer", _
        "cmdEditCustomer", "cmdEditContractor", "cmdComment", "cmdSave", _
        "lblEmailWarning", "cmdClearAndStartNew"
        ilsh.Range.Font.Hidden = False
        End Select
    End If
   
    Next ilsh
Else
    MsgBox "Can not Print Please first correct entries"
    Exit Sub
End If

End Sub
0
Comment
Question by:Taras
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 23

Expert Comment

by:irudyk
ID: 22683023
Try turning the screen updating off and then back on using Application.ScreenUpdating = False and Application.ScreenUpdating = True
Try the revised code below

Private Sub cmdPrint_Click()
 
Application.ScreenUpdating = False 
 
'First we validate entries
Dim EntriesComplete As Boolean
EntriesComplete = False
'Call validate procedure ValidateServiceEntries
EntriesComplete = ValidateServiceEntries
 
Dim ilsh As InlineShape
 
If EntriesComplete = True Then
    For Each ilsh In ActiveDocument.InlineShapes
    If ilsh.Type = wdInlineShapeOLEControlObject Then
        Select Case ilsh.OLEFormat.Object.Name
           
        Case "cmdPrint", "cmdSandEmail", "cmdSalesmanInfo", "cmdEditCustomer", _
        "cmdEditCustomer", "cmdEditContractor", "cmdComment", "cmdSave", _
        "lblEmailWarning", "cmdClearAndStartNew"
        ilsh.Range.Font.Hidden = True
        End Select
    End If
    
        Next ilsh
    'print document without cm buttons
    ActiveDocument.PrintOut
 
    'put buttons back
    For Each ilsh In ActiveDocument.InlineShapes
    
    If ilsh.Type = wdInlineShapeOLEControlObject Then
        Select Case ilsh.OLEFormat.Object.Name
        Case "cmdPrint", "cmdSandEmail", "cmdSalesmanInfo", "cmdEditCustomer", _
        "cmdEditCustomer", "cmdEditContractor", "cmdComment", "cmdSave", _
        "lblEmailWarning", "cmdClearAndStartNew"
        ilsh.Range.Font.Hidden = False
        End Select
    End If
    
    Next ilsh
Else
    MsgBox "Can not Print Please first correct entries"
End If
 
Application.ScreenUpdating = True
 
End Sub

Open in new window

0
 

Author Comment

by:Taras
ID: 22684014
I did it but still the same
0
 
LVL 23

Accepted Solution

by:
irudyk earned 1500 total points
ID: 22684279
Hmm, well setting the ScreenUpdating usually does the job.  If not in your case, then I'd have to see a sample file to be able to test with.  The other option is to set the document to print Draft Output.  Doing so will not print the buttons without you having to the button's font hidden (which I'm presuming is the cause of the flickering).  So something like
Private Sub cmdPrint_Click()
 
Application.ScreenUpdating = False 
 
'First we validate entries
Dim EntriesComplete As Boolean
EntriesComplete = False
'Call validate procedure ValidateServiceEntries
EntriesComplete = ValidateServiceEntries
 
Dim ilsh As InlineShape
 
If EntriesComplete = True Then
    Options.PrintDraft = True
    ActiveDocument.PrintOut
    Options.PrintDraft = False
Else
    MsgBox "Can not Print Please first correct entries"
End If
 
Application.ScreenUpdating = True
 
End Sub

Open in new window

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
This article describes how to use the Send to Mail Recipient command. The instructions apply generally to Office 2007 and later versions, but Microsoft® Word 2013 was used for the specific steps and figures.  What is Send to Mail Recipient? Send…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question