Identifying bullets using VB Script?

M

Mike T.

I have a Word 2003 template that I strip all of the FormField values
off of using code such as:

strCurrentResult = objWord.ActiveDocument.FormFields(CStr(InArrFields
(lngCurrentArrayPosition))).Result

This works fine. Since I pass in an array of field names. I evaluate
the strCurrentResult variable for things like parenthesis because they
need slashes in front of them to work correctly with a printer (e.g. "\
(" ). One item that recently was identified was the bullets not being
printed. The obvious explanation is that I'm not identifying them when
parsing. Is there a way to identify whether the variable contains a
bullet (the default one Word 2003 uses)? I have tried to identify for
AscW(8226) (Unicode bullet) but that doesn't seem to work.
 
D

Doug Robbins - Word MVP

I doubt that the paragraph formatting that causes the bullet to appear is
part of the .Result of the formfield. That being the case, you would need
to be doing something other than evaluating the strCurrentResult to
determine whether that .Result appears inside a bulleted list.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
M

Mike T.

Doug,

Thanks for the reply, the word document I'm using is Protected against
everything but filling in form fields. I have tried to parse the
information character for character using the following code:

Dim intCounter
Dim intLen
Dim arrChars()

intLen = Len(oRange.Text)-1
redim arrChars(intLen)

For intCounter = 0 to intLen
arrChars(intCounter) = Mid(oRange.Text, intCounter + 1,1)
MsgBox "Value: " & arrChars(intCounter) & "Asc: " & AscW(arrChars
(intCounter))
Next

Unfortunately when I try to identify the bullet it doesn't seem to
work correctly. I've also tried to use the .Find method using code
similar to the following:

With objDocument.Content.Find
.ClearFormatting
.Text = AscW(8226)
.Replacement.Text = "hello"
.Execute
End With

Unfortunately I don't think AscW(8226) finds the bullet correctly.

Thanks
 
D

Doug Robbins - Word MVP

Try running a macro containing the following code

ActiveDocument.ConvertNumbersToText

Before running that, I am not able to select just the bullet itself. After
running that code, I can select just a bullet itself and then running MsgBox
AscW(Selection) returns "-3913"

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

Doug,

Thanks for the reply, the word document I'm using is Protected against
everything but filling in form fields. I have tried to parse the
information character for character using the following code:

Dim intCounter
Dim intLen
Dim arrChars()

intLen = Len(oRange.Text)-1
redim arrChars(intLen)

For intCounter = 0 to intLen
arrChars(intCounter) = Mid(oRange.Text, intCounter + 1,1)
MsgBox "Value: " & arrChars(intCounter) & "Asc: " & AscW(arrChars
(intCounter))
Next

Unfortunately when I try to identify the bullet it doesn't seem to
work correctly. I've also tried to use the .Find method using code
similar to the following:

With objDocument.Content.Find
.ClearFormatting
.Text = AscW(8226)
.Replacement.Text = "hello"
.Execute
End With

Unfortunately I don't think AscW(8226) finds the bullet correctly.

Thanks
 
M

Mike T.

Doug,

Thanks for the reply. I was using VB Script outside of Word to parse
this stuff so I just made a macro so I could just start
troubleshooting it. I started small with:

Dim collParagraphs As Paragraphs
Dim oRange As Range
Dim Index As Integer

Set collParagraphs = ActiveDocument.Paragraphs

For Index = 1 To collParagraphs.Count
Set oRange = collParagraphs(Index).Range

Dim intCounter
Dim intLen
Dim arrChars()

intLen = Len(oRange.Text) - 1
ReDim arrChars(intLen)

For intCounter = 0 To intLen
arrChars(intCounter) = Mid(oRange.Text, intCounter + 1, 1)
MsgBox "Value: " & arrChars(intCounter) & vbNewLine & "AscW: "
& AscW(arrChars(intCounter))
Next

Next

Set oRange = Nothing

By not using what you recommended a bullet in the body would be
invisible, except for the case of a bullet within a form field. On a
Protected Document (which is what I use) the only way to get a bullet
in there is to copy it from another Word Document and paste it in a
Form Field (this is exception handling of sorts that I'm dealing
with....). With that in mind the bullet within the formfield was
identified using the AscW function as 8226.

Then I added your suggestion of ActiveDocument.ConvertNumbersToText at
the beginning of the macro. The only change I saw was that a bullet
within the body and not within a formfield was able to be identified
with a return value of -3913 from the AscW function.

Applying this information in a meaningful way is the next objective. I
really don't want to parse character by character through multiple
page letters. Is there a recommendation for ways to find the character
(regardless if it's -3913 or 8226)?

Thanks again for your response.

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

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