Solved

word template flickering

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

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