Computer Forum Forum Index
Register  FAQ Profile Log in to check your private messages Log in Register 

Text box test change

 
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba beginners
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Thu Nov 08, 2007 11:30 am    Post subject: Text box test change Reply with quote

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
Back to top
Google
Sponsor





PostPosted: Thu Nov 08, 2007 11:30 am    Post subject: Advertisement

Back to top
Helmut Weber
Guest





PostPosted: Thu Nov 08, 2007 11:53 am    Post subject: Re: Text box test change Reply with quote

Hi Matthew,

see:

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

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

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Computer Forum Forum Index -> microsoft word vba beginners All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Computer Forum