Reply
 
Thread Tools Display Modes
  #1   Report Post  
instant000 instant000 is offline
Junior Member
 
Posts: 1
Post Search and Insert, Search and Replace, Modify Document Margins

Basically, I have inherited a macro, and I need to modify it.

How do I do the following in a Macro?

Search for specific text?
Example, if I want to locate the string "FINAL INVOICE"
Insert an image before the string?
How do I insert an image, say c:\logo.jpg ?


Is this correct:

' Find Final Invoice and Set font size for header
' Set myRange = ActiveDocument.Content
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=20
' Selection.MoveDown Unit:=wdLine, Count:=20
Selection.Find.Text = "FINAL INVOICE"
While Selection.Find.Execute = True

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\logo9.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Selection.MoveDown Unit:=wdLine, Count:=18, Extend:=wdExtend
Selection.Font.Size = 11
Selection.MoveDown Unit:=wdLine, Count:=20
Wend

' Find Commerical Invoice and Set font size for header
' Set myRange = ActiveDocument.Content
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=20
' Selection.MoveDown Unit:=wdLine, Count:=20
Selection.Find.Text = "COMMERCIAL INVOICE"
While Selection.Find.Execute = True

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\logo9.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Selection.MoveDown Unit:=wdLine, Count:=18, Extend:=wdExtend
Selection.Font.Size = 11
Selection.MoveDown Unit:=wdLine, Count:=20
Wend



How do I replace text I searched for?
Say, I want to replace the text XXuser01 with an image XXuser01.jpg?

Is this correct:

' Place Paul's signature on the commercial invoice
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.Find.Text = "XXX USER 97"
While Selection.Find.Execute = True
Selection.TypeBackspace
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\user97.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Wend

How do I modify document margins?
Originally, the document might fit on A4, but I only have 8.5 x 11 to print it out on. Is there any way to increase the margins inside the macro?

Is this it?
' Increase Margin's

With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = InchesToPoints(0.15)
.BottomMargin = InchesToPoints(0.1)
.LeftMargin = InchesToPoints(0.25)
.RightMargin = InchesToPoints(0.15)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(8.26)
.PageHeight = InchesToPoints(11.69)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = True
.MirrorMargins = False

.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With

' Set Font Size

Selection.WholeStory
Selection.Font.Size = 10
  #2   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Search and Insert, Search and Replace, Modify Document Margins

I don't know how to do this with a macro, but I know how to do it without
one. Copy your image to the Clipboard. Then search for "FINAL INVOICE" and
replace with ^c^&. ^c represents the Clipboard contents and ^& represents
the found text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"instant000" wrote in message
...

Basically, I have inherited a macro, and I need to modify it.

How do I do the following in a Macro?

Search for specific text?
Example, if I want to locate the string "FINAL INVOICE"
Insert an image before the string?
How do I insert an image, say c:\logo.jpg ?


Is this correct:

' Find Final Invoice and Set font size for header
' Set myRange = ActiveDocument.Content
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=20
' Selection.MoveDown Unit:=wdLine, Count:=20
Selection.Find.Text = "FINAL INVOICE"
While Selection.Find.Execute = True

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\logo9.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Selection.MoveDown Unit:=wdLine, Count:=18, Extend:=wdExtend
Selection.Font.Size = 11
Selection.MoveDown Unit:=wdLine, Count:=20
Wend

' Find Commerical Invoice and Set font size for header
' Set myRange = ActiveDocument.Content
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=20
' Selection.MoveDown Unit:=wdLine, Count:=20
Selection.Find.Text = "COMMERCIAL INVOICE"
While Selection.Find.Execute = True

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\logo9.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Selection.MoveDown Unit:=wdLine, Count:=18, Extend:=wdExtend
Selection.Font.Size = 11
Selection.MoveDown Unit:=wdLine, Count:=20
Wend



How do I replace text I searched for?
Say, I want to replace the text XXuser01 with an image XXuser01.jpg?

Is this correct:

' Place Paul's signature on the commercial invoice
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.Find.Text = "XXX USER 97"
While Selection.Find.Execute = True
Selection.TypeBackspace
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\user97.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Wend

How do I modify document margins?
Originally, the document might fit on A4, but I only have 8.5 x 11 to
print it out on. Is there any way to increase the margins inside the
macro?

Is this it?
' Increase Margin's

With ActiveDocument.PageSetup
LineNumbering.Active = False
Orientation = wdOrientPortrait
TopMargin = InchesToPoints(0.15)
BottomMargin = InchesToPoints(0.1)
LeftMargin = InchesToPoints(0.25)
RightMargin = InchesToPoints(0.15)
Gutter = InchesToPoints(0)
HeaderDistance = InchesToPoints(0.5)
FooterDistance = InchesToPoints(0.5)
PageWidth = InchesToPoints(8.26)
PageHeight = InchesToPoints(11.69)
FirstPageTray = wdPrinterDefaultBin
OtherPagesTray = wdPrinterDefaultBin
SectionStart = wdSectionNewPage
OddAndEvenPagesHeaderFooter = False
DifferentFirstPageHeaderFooter = False
VerticalAlignment = wdAlignVerticalTop
SuppressEndnotes = True
MirrorMargins = False

TwoPagesOnOne = False
GutterPos = wdGutterPosLeft
End With

' Set Font Size

Selection.WholeStory
Selection.Font.Size = 10




--
instant000


  #3   Report Post  
Posted to microsoft.public.word.formatting.longdocs
Suzanne S. Barnhill Suzanne S. Barnhill is offline
external usenet poster
 
Posts: 33,624
Default Search and Insert, Search and Replace, Modify Document Margins

I don't know how to do this with a macro, but I know how to do it without
one. Copy your image to the Clipboard. Then search for "FINAL INVOICE" and
replace with ^c^&. ^c represents the Clipboard contents and ^& represents
the found text.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
http://word.mvps.org

"instant000" wrote in message
...

Basically, I have inherited a macro, and I need to modify it.

How do I do the following in a Macro?

Search for specific text?
Example, if I want to locate the string "FINAL INVOICE"
Insert an image before the string?
How do I insert an image, say c:\logo.jpg ?


Is this correct:

' Find Final Invoice and Set font size for header
' Set myRange = ActiveDocument.Content
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=20
' Selection.MoveDown Unit:=wdLine, Count:=20
Selection.Find.Text = "FINAL INVOICE"
While Selection.Find.Execute = True

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\logo9.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Selection.MoveDown Unit:=wdLine, Count:=18, Extend:=wdExtend
Selection.Font.Size = 11
Selection.MoveDown Unit:=wdLine, Count:=20
Wend

' Find Commerical Invoice and Set font size for header
' Set myRange = ActiveDocument.Content
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=20
' Selection.MoveDown Unit:=wdLine, Count:=20
Selection.Find.Text = "COMMERCIAL INVOICE"
While Selection.Find.Execute = True

Selection.MoveLeft Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.Delete Unit:=wdCharacter, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\logo9.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Selection.MoveDown Unit:=wdLine, Count:=18, Extend:=wdExtend
Selection.Font.Size = 11
Selection.MoveDown Unit:=wdLine, Count:=20
Wend



How do I replace text I searched for?
Say, I want to replace the text XXuser01 with an image XXuser01.jpg?

Is this correct:

' Place Paul's signature on the commercial invoice
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.Find.Text = "XXX USER 97"
While Selection.Find.Execute = True
Selection.TypeBackspace
Selection.InlineShapes.AddPicture FileName:= _
"M:\logo\user97.jpg", LinkToFile:=False, SaveWithDocument:= _
True
Wend

How do I modify document margins?
Originally, the document might fit on A4, but I only have 8.5 x 11 to
print it out on. Is there any way to increase the margins inside the
macro?

Is this it?
' Increase Margin's

With ActiveDocument.PageSetup
LineNumbering.Active = False
Orientation = wdOrientPortrait
TopMargin = InchesToPoints(0.15)
BottomMargin = InchesToPoints(0.1)
LeftMargin = InchesToPoints(0.25)
RightMargin = InchesToPoints(0.15)
Gutter = InchesToPoints(0)
HeaderDistance = InchesToPoints(0.5)
FooterDistance = InchesToPoints(0.5)
PageWidth = InchesToPoints(8.26)
PageHeight = InchesToPoints(11.69)
FirstPageTray = wdPrinterDefaultBin
OtherPagesTray = wdPrinterDefaultBin
SectionStart = wdSectionNewPage
OddAndEvenPagesHeaderFooter = False
DifferentFirstPageHeaderFooter = False
VerticalAlignment = wdAlignVerticalTop
SuppressEndnotes = True
MirrorMargins = False

TwoPagesOnOne = False
GutterPos = wdGutterPosLeft
End With

' Set Font Size

Selection.WholeStory
Selection.Font.Size = 10




--
instant000


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
search-replace Narendra Boga Microsoft Word Help 5 May 12th 08 03:30 AM
how do I search and replace hyperlinks in a word document. Jen Microsoft Word Help 1 January 9th 07 02:01 AM
Search and Replace Jackie Formatting Long Documents 0 October 20th 05 10:23 AM
Search/replace entire document, excluding one style BerkeleyBecca Microsoft Word Help 0 June 1st 05 12:20 AM
Search/replace entire document, excluding one style Martin P Microsoft Word Help 1 June 1st 05 12:16 AM


All times are GMT +1. The time now is 07:32 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"