Converting VBA Code to VB to Use in Code Stage
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
14-07-22 05:19 PM
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 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.
Thank you!
------------------------------
Sean Scudellari
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
14-07-22 08:26 PM
I think that BP is not recognising the Paragraph data item cause you don't have added the Interop dll
Try checking this configuration for the VBO:
I think, the best way to this is to create a new page in this VBO: https://digitalexchange.blueprism.com/dx/entry/3439/solution/ms-word-vbo
This code does not return any compilation errors but I cannot test it.
Dim doc as Object = GetDocument(handle,documentname)
Dim range As Object
Dim Para As Paragraph
For Each Para In ActiveDocument.Paragraphs
If Para.Range.ListFormat.ListType = wdListBullet Then
'do something
End If
Next Para
Try with this!
Hope this helps you!
See you in the Community, bye 🙂
------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
14-07-22 09:55 PM
Thank you @Pablo Sarabia! I was created this custom action within the Microsoft Word VBO as you mentioned. This is what my configuration looks like in the Word VBO:
I believe this matches your picture, correct? Or is there anything else I need to change within this configuration? Also, I'm using Word 2010. Perhaps this interop dll is not compatible with Word 2010?
------------------------------
Sean Scudellari
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
14-07-22 10:18 PM
I think it doesn't matter which version. What error do you get when you create a page within that VBO?
Is the exact code you use the one you indicated above?
Bye 🙂
------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
14-07-22 10:28 PM
Thank you.
------------------------------
Sean Scudellari
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-07-22 01:10 AM
Try using this code at line number 5. It should ideally work:
Dim Para As Microsoft.Office.Interop.Word.Paragraph
------------------------------
----------------------------------
Hope it helps you out and if my solution resolves your query, then please mark it as the 'Best Answer' so that the others members in the community having similar problem statement can track the answer easily in future
Regards,
Devneet Mohanty
Intelligent Process Automation Consultant | Sr. Consultant - Automation Developer,
WonderBotz India Pvt. Ltd.
Blue Prism Community MVP | Blue Prism 7x Certified Professional
Website: https://devneet.github.io/
Email: devneetmohanty07@gmail.com
----------------------------------
------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-07-22 02:01 AM
Thank you, Devneet. I updated my code and am no longer getting an error, however, the output I get is "System.__ComObject"
I feel like I am pretty close to getting this and just need to find a way to get the values in the output.
Appreciate your help!
------------------------------
Sean Scudellari
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-07-22 03:41 AM
To get the text from a paragraph use this:
result = Para.Range.Text
But, with this you only get one of the texts. Do you want to get a collection of all the texts or something similar?
Bye 🙂
------------------------------
Pablo Sarabia
Solution Manager & Architect
Altamira Assets Management
Madrid
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-07-22 03:24 PM
You might find this page useful for any future vba conversion to vb Converting Code from VBA to Visual Basic .NET | Microsoft Docs
------------------------------
Michael ONeil
Technical Lead developer
NTTData
Europe/London
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
15-07-22 05:45 PM
Also, if I wanted to extract only the bullet points from a certain section of the document, how would I do that? The range of each document I need to process will be different (each will have a different number of characters, so would be hard to use a 'start' and 'finish' input variables within a range). However, the text that comes before and after the specific bullet points will be same in each document.
For example, the document would look like this:
Section 1 - Header
Bullet 1
Bullet 2
Bullet 3
Section 2 - Header
I would like to get the bullet point text only between section 1 and section 2 of the document, but the section 1 and section 2 may be in a different range within each document I need to process, but their sections headings/titles will always be the same. Thank you so much for the help, I greatly appreciate it!
------------------------------
Sean Scudellari
------------------------------
