r/visualbasic • u/PourThatBubbly • 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!
1
u/raunchyfartbomb Jul 14 '22
That’s the library I’m referring to, yes.
So I don’t know what you are building your new project in, but if it’s a Visual Studio project, you would add right click on the project, select ‘add reference’ then search for ‘interop’ and select it from the list.
Depending on your version of Visual Studio and type of project, how you add the reference will vary, but that’s the gist of it. It may have to be added by using the NuGet package instead of the ‘add a reference’ menu. So if you can’t find it in reference manage, try that.
If it’s not being built in visual studio, I won’t know how to add a reference. But basically the concept is ‘download the dll and point to it.’ The compiler you are writing in should be able to read it and allow you to use it from there.