---
title: "Fetmarkera text i Word (VBA)"
type: "forum-thread"
url: "https://www.webforum.nu/amne/dotnet/178782-fetmarkera-text-i-word-vba"
topic: ".NET"
topic_url: "https://www.webforum.nu/amne/dotnet"
author: "Pedda"
published: "2009-05-28T20:43:32.000Z"
updated: "2009-05-30T19:54:45.000Z"
replies: 4
views: 748
page: 1
pages: 1
language: "sv-SE"
site: "webForum — webforum.nu"
rights: "Upphovsrätten till varje inlägg tillhör dess författare."
attribution: "Citera som: webForum, https://www.webforum.nu/amne/dotnet/178782-fetmarkera-text-i-word-vba"
---

# Fetmarkera text i Word (VBA)

## #1 — Pedda, 2009-05-28T20:43Z

Håller på med ett macro och har fått till det mesta, men har problem med att fetmarkera en del texter.

Jag har en array med strängar som ska fetmarkeras.
Loopen går som den ska, men ingen text fetmarkeras.

```
For Each boldText In boldArray
    Selection.Find.ClearFormatting
    With Selection.Find
        .Text = boldText
        .Replacement.Text = ""
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Font.Bold = wdToggle
Next
```

Någon som kan se vad jag gör för fel?

Permalänk: https://www.webforum.nu/p/178782

## #2 — Pedda, 2009-05-29T16:51Z

Problemet löst efter lite ombyggnad.

Permalänk: https://www.webforum.nu/p/2186138

## #3 — colione, 2009-05-30T16:59Z

Du kan ju posta lösningen också.  ;)

Permalänk: https://www.webforum.nu/p/2186175

## #4 — Pedda, 2009-05-30T18:13Z

Japp, men jag har den på jobbet.  :)
Kommer på måndag om jag kommer ihåg det.

Permalänk: https://www.webforum.nu/p/2186179

## #5 — Pedda, 2009-05-30T19:54Z

Tror att det var så här jag löste det:

```
For Each boldText In boldArray
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = boldText
        .Replacement.Text = boldText
        .Replacement.Font.Bold = True
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = True
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
Next
```

Permalänk: https://www.webforum.nu/p/2186185

---

Tråden på webben: https://www.webforum.nu/amne/dotnet/178782-fetmarkera-text-i-word-vba
