Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

excel macro

  • 26-05-2005 12:17PM
    #1
    Closed Accounts Posts: 202 ✭✭


    ok, I got this problem were I have to open a word doc from excel, find a word in the doc, and then replace it with another word(I can do these). the problem is that when I replace the word I have to change the font to Wingdings.

    I've tried just putting the line "selection.font.name = 'Wingdings'" into the find and replace sub but it doesn't work.

    I'm thinking I'm just putting it in the wrong place or something

    here's my code for the find and replace sub:

    Sub FindRep2(target As String, source As String)

    wordApp.Selection.Find.ClearFormatting
    wordApp.Selection.Find.Replacement.ClearFormatting
    wordApp.Selection.Find.Replacement.Font.Name = "Wingdings"
    With wordApp.Selection.Find
    .Text = target
    .Replacement.Text = source
    .Forward = True
    .Wrap = wdFindContinue
    .Format = False
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False

    .Execute Replace:=wdReplaceAll
    End With



    thanks

    Rob


Comments

  • Closed Accounts Posts: 35 Ivan Dunaev


    try .Format = True instead of .Format = False


  • Closed Accounts Posts: 202 ✭✭eyebrows


    OMG. I was tyring to get that working for ages and it was this fecken thing
    try .Format = True instead of .Format = False

    fúcking me up the whole time.

    cheers Ivan


Advertisement