Solved

word template flickering

Posted on 2008-10-09
3
271 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 500 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

Suggested Solutions

There is a feature provided by MS Word that lets you create an Table of Contents for your Word document automatically. To use this feature for other documents there are two steps involved,   1.  Prepare your document for a table of contents (he…
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 walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

726 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