Solved

word template flickering

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

It is often necessary in this forum and others to illustrate Word fields as text with the field delimiters replaced with the curly brackets that the delimiters resemble when field codes are being displayed on the document. This means that the text c…
If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …

770 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