Wrox Programmer Forums
|
Word VBA Discuss using VBA to program Word.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2008, 04:54 AM
Registered User
 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to JackHack
Default Word macro...help

Hi,

I got to format the document before uploading it to the client...formating the whole doc is very time consuming... Here is the sample of the docu...
------

Operator

[Some Text]

Matt Stand – Investor Relations

[Some Text]

and so on...this type goes on through the end of doc...
--------------

Now what i do with this is i change the formating like this

-------
first the whole document i got to convert it to Arial text and size 12 and of color gray. After this it goes like this

Operator (this whole part i change it to Arial text and size 14, bold and of color dark red)

[Some Text] (no change)

Matt Stand – Investor Relations (this part i got to change it to Arial text and size 14, bold and of color dark red, but only after the hypen the text is italics)

[Some Text]

so this goes on throughout the doc...

---------------

Can someone help me with the VBA coding to make the task simple...hope u guys have understood what i want..thx.
 
Old October 13th, 2008, 07:27 AM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hey Jack

Here is a hint

Code:
Sub Change_Font_For_Jack()

Dim oRange As Word.Range

Set oRange = ActiveDocument.Range

oRange.Font.Name = "Arial"
oRange.Font.Size = "12"
oRange.Font.Color = wdColorGray75

oRange.Collapse WdCollapseDirection.wdCollapseEnd

Selection.HomeKey wdStory, wdMove
Selection.Find.Execute "Matt Stand – Investor Relations"
Do While Selection.Find.Found
    With Selection.Range
        .Font.Name = "Arial"
        .Font.Size = "14"
        .Font.Color = vbRed
    End With
    Selection.Find.Execute "Investor Relations"
    Selection.Font.Italic = True
    Selection.Collapse WdCollapseDirection.wdCollapseEnd
    Selection.Find.Execute "Matt Stand – Investor Relations"
Loop

End Sub
Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
 
Old October 13th, 2008, 02:05 PM
Registered User
 
Join Date: Oct 2008
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to JackHack
Default

Hi Shasur,

Thx for the code, made some changes a bit in that, but really was of help...

Thx again. Happy Coding. :)

JackHack..





Similar Threads
Thread Thread Starter Forum Replies Last Post
calling to xlam macro from macro inside xlsb SteveB Excel VBA 0 June 30th, 2008 06:43 PM
Macro for Auto-filling a pre-made Word form dan_thorman Excel VBA 0 January 25th, 2007 10:46 AM
Word Macro Arul20 Beginning VB 6 1 June 6th, 2005 08:18 AM
Disable Word Macro from C Shap nna C# 0 March 30th, 2004 06:23 AM
Copying some part of the doc using macro in word Lakshmi KS Access VBA 2 December 5th, 2003 05:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.