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 / October 2005

Tip: Looking for answers? Try searching our database.

Locating and changing formatting

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BurtArkin - 05 Oct 2005 20:59 GMT
I am importing large amounts of data for a quasi-legal document into Word,
from Access, using mailmerge.  I have set markers in the text being imported,
like "<ZZ" and "BLD".  <ZZ is converted to a tab easily enough with a short
macro.  BLD is placed at the front of a line I want to change to boldface or
italic.  How do I do this with a macro?  I'd appreciate any help you can
gfive.  Thanks.
Signature

Burt

Ness - 06 Oct 2005 11:02 GMT
Burt,
Try:
Selection.Find.ClearFormatting
   With Selection.Find
       .Text = "bld"
       .Replacement.Text = ""
       .Forward = True
       .Wrap = wdFindContinue
End With
   Selection.Find.Execute
   Selection.EndKey Unit:=wdLine, Extend:=wdExtend
'to change line to bold
   Selection.Font.Bold = wdToggle
'to change to italic
   Selection.Font.Italic = wdToggle

Hope this helps

> I am importing large amounts of data for a quasi-legal document into Word,
> from Access, using mailmerge.  I have set markers in the text being imported,
> like "<ZZ" and "BLD".  <ZZ is converted to a tab easily enough with a short
> macro.  BLD is placed at the front of a line I want to change to boldface or
> italic.  How do I do this with a macro?  I'd appreciate any help you can
> gfive.  Thanks.
BurtArkin - 06 Oct 2005 14:37 GMT
Thank you for your response.  It works, but only for a single instance of the
"BLD" element.  There are always a variable number of markers in the doc I'm
merging, and I need to "loop" through the entire merged text.  I've attempted
to create the looping code, but I'm doing something wrong, because it never
ends.  Thanks again for your help.
Signature

Burt

> Burt,
> Try:
[quoted text clipped - 20 lines]
> > italic.  How do I do this with a macro?  I'd appreciate any help you can
> > gfive.  Thanks.
Tony Jollans - 06 Oct 2005 12:31 GMT
When you say "line" what exactly do you mean? Word doesn't really have a
line as a unit because it depends on the printer being used.

It is possible to select what you see as a line on the screen (and to do it
in code with the Selection object) but if when you say "line" you mean text
that is actually delimited in some other way - perhaps with a new line mark
or paragraph mark - then the changes you want could be quite easily done
with Find/Replace (and code could be recorded if you want it).

As I write, I realise, of course, that code could be recorded anyway - it
would just be more complex both manually and in code if you really want to
work with a 'screen line' which is not delimited in any other way.

--
Enjoy,
Tony

> I am importing large amounts of data for a quasi-legal document into Word,
> from Access, using mailmerge.  I have set markers in the text being imported,
[quoted text clipped - 4 lines]
> --
> Burt
BurtArkin - 06 Oct 2005 14:41 GMT
Thanks for your response.  By line, I meant a paragraph header.  There are
several in the document that I merge into Word, and I want to bold and/or
italicize the lines that start with ther letters "BLD"
Signature

Burt

> When you say "line" what exactly do you mean? Word doesn't really have a
> line as a unit because it depends on the printer being used.
[quoted text clipped - 24 lines]
> > --
> > Burt
Tony Jollans - 06 Oct 2005 15:22 GMT
If I understand what you mean by "paragraph header" you should be able to
use a Find/Replace

Open up the Find/Replace Dialog
Press More if need be to see the whole thing
Check Use Wildcards

Find <BLD([!^13]{1,}^13) -- that's less than symbol, B, L, D, left
parenthesis, left (square) bracket, exclamation point, caret, one, three,
right bracket, left brace, one, comma, right brace, caret, one, three, right
parenthesis

Replace \1 -- that's backslash, one

Set Replace format to Bold (cursor in Replace, Click on Format, Select Font,
Choose Bold, Close)

Hit Replace All

(untested so I might have made a typo - or other stupid mistake :)

--
Enjoy,
Tony

> Thanks for your response.  By line, I meant a paragraph header.  There are
> several in the document that I merge into Word, and I want to bold and/or
[quoted text clipped - 30 lines]
> > > --
> > > Burt
 
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.