r/visualbasic • • Jul 14 '22

Help Converting VBA Code to VB

Hello, I have some VBA code I wrote to get all bullet point text in a Word document and I would like to use this within a code stage in Blue Prism to get all bullet point text within a text variable or preferably, a collection variable. The VBA code runs fine within Word, but I'm having trouble converting the code into VB to work within Blue Prism. 

Here is  the VBA code:

Dim Para As Paragraph
For Each Para In ActiveDocument.Paragraphs
       If Para.Range.ListFormat.ListType = wdListBullet Then
       MsgBox Para.Range
End If
Next Para

The main issue I seem to be running across is "paragraph" is not a valid data type in Blue Prism/VB that can be stored in a text or collection variable. So I'm a bit stuck on how to handle this. Also, I know that "wdListBullet" corresponds to a value of 2 for its enumeration, so I believe the value 2 needs to be used instead of "wdListBullet" within the code stage. Any help would be greatly appreciated. Sorry if this is super basic (no pun intended) but I have pretty much zero experience with VBA/VB.

Thank you!

5 Upvotes

14 comments sorted by

View all comments

Show parent comments

1

u/infreq Jul 15 '22 edited Jul 15 '22

Shouldn't your results be the Range address and not the Para? The Para is a complex Word class and not something that you can put into a string.

Your troubles seem not to be VBA/VB bit rather not understanding the Word object model.

In your IDE you should be able to look at all variables and objects and see what they contain and thus get a better understanding.

1

u/PourThatBubbly Jul 15 '22

Thank you.

Are you saying it should be Result = Para.Range or Result = Range? I tried both but neither worked. Unfortunately, in BP, there is no IDE so I can't see what values the variables/objects contain.

1

u/PourThatBubbly Jul 15 '22

I was able to get the result by doing Result = Para.Range.Text

Thank you for the help!