Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Text box test change

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
matthew.rodwell@luptonfawcett.com - 08 Nov 2007 11:30 GMT
hi all....my code is below...i want to be able to change a certain
word in my document to another but it fails to change the text in the
text box at the top of my page....any help please

Selection.Find.ClearFormatting
   Selection.Find.Replacement.ClearFormatting
   With Selection.Find
       .Text = "firm name"
       .Replacement.Text = "new firm name"
       .Forward = True
       .Wrap = wdFindContinue
       .Format = False
       .MatchCase = False
       .MatchWholeWord = False
       .MatchWildcards = False
       .MatchSoundsLike = False
       .MatchAllWordForms = False
   End With
   Selection.Find.Execute Replace:=wdReplaceAll

   If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
       ActiveWindow.Panes(2).Close
   End If
   If ActiveWindow.ActivePane.View.Type = wdNormalView Or
ActiveWindow. _
       ActivePane.View.Type = wdOutlineView Then
       ActiveWindow.ActivePane.View.Type = wdPrintView
   End If
   ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
   Selection.MoveDown Unit:=wdScreen, Count:=4
   With ActiveDocument.Styles(wdStyleNormal).Font
       If .NameFarEast = .NameAscii Then
           .NameAscii = ""
       End If
       .NameFarEast = ""
   End With
   With ActiveDocument.PageSetup
       .LineNumbering.Active = False
       .Orientation = wdOrientPortrait
       .TopMargin = CentimetersToPoints(2.54)
       .BottomMargin = CentimetersToPoints(4)
       .LeftMargin = CentimetersToPoints(2)
       .RightMargin = CentimetersToPoints(2)
       .Gutter = CentimetersToPoints(0)
       .HeaderDistance = CentimetersToPoints(1.25)
       .FooterDistance = CentimetersToPoints(0.4)
       .PageWidth = CentimetersToPoints(21)
       .PageHeight = CentimetersToPoints(29.7)
       .FirstPageTray = wdPrinterDefaultBin
       .OtherPagesTray = wdPrinterDefaultBin
       .SectionStart = wdSectionNewPage
       .OddAndEvenPagesHeaderFooter = False
       .DifferentFirstPageHeaderFooter = True
       .VerticalAlignment = wdAlignVerticalTop
       .SuppressEndnotes = False
       .MirrorMargins = False
       .TwoPagesOnOne = False
       .BookFoldPrinting = False
       .BookFoldRevPrinting = False
       .BookFoldPrintingSheets = 1
       .GutterPos = wdGutterPosLeft
       .SectionDirection = wdSectionDirectionLtr
   End With
   Selection.WholeStory
   Selection.Delete Unit:=wdCharacter, Count:=1
   Application.DisplayAutoCompleteTips = True
   NormalTemplate.AutoTextEntries("SFooter.TXT").Insert
Where:=Selection.Range _
       , RichText:=True
   'Selection.TypeBackspace
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

'PrinterNow = ActivePrinter      'Gets current printer
'vIsALetterPrinter = True        'This IS a Letter printer

'vLetterPrinter = "\\LFDATA1\HPC4-1"   'Sets the letter printer name
'vCopyPrinter = "\\LFDATA1\HPC4-1"     'Sets the copy printer
   '
'frmPrinting.Show                'Displays print dialog box

'Call DoSelectPrinter            'Selects the correct printer
'Call DoPageSetup4345            'Selects the correct bins
'Call DoPrinting4345             'Prints the document (& copy if
required)
'Call DoSaving                   'Saves if required

'If PrinterNow <> ActivePrinter Then
'    ActivePrinter = PrinterNow      'Sets default printer back to
original
'End If
End Sub
Helmut Weber - 08 Nov 2007 11:53 GMT
Hi Matthew,

see:

http://gregmaxey.mvps.org/VBA_Find_And_Replace.htm

http://word.mvps.org/faqs/customization/replaceanywherecontent.htm

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.