Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-28-2017, 01:40 PM
Welshgasman Welshgasman is offline Application.ScreenUpdating not working? Windows 7 32bit Application.ScreenUpdating not working? Office 2003
Novice
Application.ScreenUpdating not working?
 
Join Date: Jun 2011
Posts: 26
Welshgasman is on a distinguished road
Default Application.ScreenUpdating not working?

Hi all,


Before I start, I will admit I posted this in a forum that helps me a lot with another Office product, but as of this post they were not able to shed any light on this issue.

I created the code below which does what it was written for, BUT the screen updates whilst it runs.
The screen flickers (presumably when opening each document)?

Is there a way to suppress this.?
I was offered Appliication.Echo as a solution, but that is not recognised in Word 2007?

TIA
Code:
Sub InsertText()
Dim Shp As Shape, Doc As Document, strTextToInsert As String, strTextToFind As String
Dim i As Long, docToOpen As FileDialog, sHght As Single
Dim rngToSearch As Word.Range
Dim DataObj As New MSForms.DataObject
    
    On Error GoTo Err_Exit
    'strText = InputBox("New Text", "Header Textbox Update", "New Text")
    
    ' Switch off the updates of screen
    Application.ScreenUpdating = False
    
    ' Set the text
    strTextToInsert = "Annual bonus rates for the last five years"
    strTextToFind = "Discharge Pack"
    
    DataObj.SetText strTextToInsert
    DataObj.PutInClipboard
    
    Set docToOpen = Application.FileDialog(msoFileDialogFilePicker)
    docToOpen.Show
    For i = 1 To docToOpen.SelectedItems.Count
        'Open each document
        Set Doc = Documents.Open(FileName:=docToOpen.SelectedItems(i))
            Selection.Find.ClearFormatting
        With Selection.Find
            .Text = strTextToFind
            .Replacement.Text = ""
            .Forward = True
            .Wrap = wdFindContinue
            .Format = False
            .MatchCase = False
            .MatchWholeWord = False
            .MatchWildcards = False
            .MatchSoundsLike = False
            .MatchAllWordForms = False
        End With
        Selection.Find.Execute
        Selection.MoveRight Unit:=wdCharacter, Count:=1
        Selection.TypeParagraph
        Selection.PasteAndFormat (wdListCombineWithExistingList)
        ' The above inserts a line which creates a second page, so delete a line after
        Selection.EndKey Unit:=wdStory
        Selection.Delete Unit:=wdCharacter, Count:=1

        ActiveDocument.Close SaveChanges:=wdSaveChanges
    Next
    
    Set docToOpen = Nothing: Set Doc = Nothing
    ' Switch Screen updates back on
    Application.ScreenUpdating = True
    Exit Sub
Err_Exit:
    MsgBox Err.Description & Err.Number
End Sub
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Application.ScreenUpdating not working? What application to use? pfergy Office 1 03-12-2011 08:46 PM
Application.FileSearch cksm4 Word VBA 0 08-19-2010 02:18 PM
Application.ScreenUpdating not working? Best application to use? FrankW Office 2 06-13-2009 01:16 AM
What is Application Automation and How can I use it in VBA KramerJ Excel 0 03-30-2009 12:59 PM
Application.Caller pankajkankaria Excel 0 03-18-2009 11:48 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:00 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft