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 2005

Tip: Looking for answers? Try searching our database.

Need a macro to search for specific font type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
steve.reed@3dsolve.com - 28 Oct 2005 21:20 GMT
I am trying to write a macro that will search through a document for
text with a specific font attribute (Comic SANS MS) then copy that text
to the clipboard. After copying the text, the insertion point moves to
a summary table at the beginning of the doc, where the clipboard is
pasted into a table.  Then I search for the next occurance of the text
with the Comic SANS MS font attribute.

I can do all the other stuff, but I just can't get VBA to search and
find a font attribute.

I have tried using the Find and Replace dialog, and in normal use, I
can find the text, but recording those actions and then using it within
amacro, it will not find the text with the Comic SANS MS attribute.

I have Word 2002.  Any suggestions?
Greg Maxey - 28 Oct 2005 23:35 GMT
Steve,

Try this:

Sub Test()
Dim myRng As Range
Set myRng = ActiveDocument.Range
With myRng.Find
 .Text = ""
 .Format = True
 .Font.Name = "Comic Sans MS"
 While .Execute
   MsgBox "Here is a bit of that text: " & myRng
 Wend
End With

End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I am trying to write a macro that will search through a document for
> text with a specific font attribute (Comic SANS MS) then copy that
[quoted text clipped - 12 lines]
>
> I have Word 2002.  Any suggestions?
Robert - 02 Nov 2005 20:41 GMT
Hello Greg,
I would like to use your code for a similar task but unlike Steve I'm
not sure how to proceed further.
I want to copy into Column 1 of an existing Table all the (single)
words in a short text that have been given the Background Pattern Color
of wdBlue.  Finding them, thanks to your code, will be easy.  The rest
will not be for this Newbie.

Table(1) will already be partially complete with other data when this
macro begins.  So we need to find the first available cell in Column 1.
Then, how do we copy each single word into the Table - preferably
along with its blue background formatting if possible.
Finally, it may happen that the Table doesn't have enough rows, so the
code will need to add more at the bottom as it goes along, if
necessary. (Or will this happen automatically within VBA?)
Is all this feasible, do you think? Could you help with the coding if
it's not too onerous a task?

Thank you in advance.
Robert

Rate this thread:






 
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.