Convert integer to String

R

Ronny

Is it possible to convert a integer to string. I want to use the “counter†as
part of the string as shown below. (Text2 shall then be “Text1â€, “Text2â€,
“Text3â€, “Text4â€)


Dim Counter As Integer
Dim Text1 As String
Dim Text2 As String

For Counter = 1 To 4


Text2 = “Text†+ Counter
Text1 = ActiveDocument.Bookmarks(Text2).Range.Text

If Text1 = Text2 Then……
 
G

Graham Mayor

Text2 = "Text" & Counter

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
F

fumei via OfficeKB.com

Whenever I see things like:

ActiveDocument.Bookmarks(Text2).Range.Text

I suspect that it is a formfield. Unfortunately people often think that the
bookmark and the formfield are one and the same. They are not. Formfields
can have bookmarks, but it is very possible to have a formfield with NO
bookmark.

You find it easier to work with the actual contents of the formfield, using .
Result - rather than the bookmark Range.Text.

ActiveDocument.Formfields(Text2).Result

For example, the following displays the contents of four text formfields - in
one messagebox - using the default names of "Text1", "Text2", "Text3",
"Text4"

BTW: it is not a good idea to retain the default names of formfields.

Dim j As Long
Dim msg As String
For j = 1 To 4
msg = msg & ActiveDocument.FormFields("Text" & j).Result _
& vbCrLf
Next
MsgBox msg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top