Skip...you Excel maniac...it is for Word.
kalle82, as it is, no, you can not pass part of a string as bold. A string has no real format. It is a string.
I would seriously question having all that different text (including so many "empty" paragraphs) in ONE bookmark.
First of all, properly done with styles, you should have NO "empty" paragraphs - your vbCrLf, or in your original thread, the Selection.TypeParagraph -
at all. Using "empty" paragraphs to create space between paragraphs is a very bad use of Word.
However, since you are, in fact, doing that, it IS possible to make part of the text - after you have put it in the bookmark - bold.
Code:
Option Explicit
Sub MakePartBold()
Dim r As Range
Dim strBoldMe As String
strBoldMe = "Ange handläggarens namn och " & _
"referensnummer i svaret."
Set r = ActiveDocument.Bookmarks("bokmark3").Range
With r.Find
.ClearFormatting
.Replacement.Font.Bold = True
.Execute Findtext:=strBoldMe, _
Forward:=False, Replace:=True
End With
End Sub
This goes through the contents of the bookmark and makes the string strBoldMe - set as "Ange handläggarens namn och referensnummer i svaret." - bold.
You could do this separate, after you put the text in of course; OR you could adjust your bookmark filling procedure to accept a third parameter (the string to be bolded). If you went that route, you would
have to action the bolding AFTER you have:
1. put the text into the bookmark
2. created the bookmark again
BTW: it would be cleaner to pass the long string you have to your UpdateBookmark procedure as a string variable, rather than a string literal.
Code:
Dim strIn As String
strIn = " och ska skickas till:" & _
vbCrLf & vbCrLf & "Kassaregisterfunktionen" & _
vbCrLf & "Skattekontor 2 Göteborg" & _
vbCrLf & "Box 28 25" & vbCrLf & _
"403 20 Göteborg" & vbCrLf & vbCrLf & _
"Ange handläggarens namn och referensnummer i svaret." & _ vbCrLf & vbCrLf & vbCrLf
Call UpdateBookmark ("bokmark3", strIn)
If you wanted to pass in the string part to be bolded, you need to change the UpdateBook procedure itself.
Sub UpdateBookmark (strBM_Name As String, _
strText As String, _
strBoldThis As String)
Then you could do:
Code:
Dim strIn As String
Dim strBoldThis As String
strIn = " och ska skickas till:" & _
vbCrLf & vbCrLf & "Kassaregisterfunktionen" & _
vbCrLf & "Skattekontor 2 Göteborg" & _
vbCrLf & "Box 28 25" & vbCrLf & _
"403 20 Göteborg" & vbCrLf & vbCrLf & _
"Ange handläggarens namn och referensnummer i svaret." & _ vbCrLf & vbCrLf & vbCrLf
strBoldThis = "Ange handläggarens namn och referensnummer i svaret."
Call UpdateBookmark ("bokmark3", strIn, strBoldThis)
Gerry