Problem using code involving Excel VBO - 'It may be inaccessible due to its protection level'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 12:10 PM
When I test the code, I get error messages on 'Columns' and 'GetWorkbook' saying 'they are not declared. It may be inaccessible due to its protection level.'
I used the info on this site to add
Microsoft.VisualBasic.dll
as an entry in the "External References" section of the Code Options tab. Microsoft.VisualBasic was already entered under 'Namespace imports'.It didn't work though... Is there another dll I should add for these functions? Thank you.
------------------------------
Michelle
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 01:10 PM
Can you check if you have the function "GetWorkbook" in the Global Code tab of the Business Object Properties?
I check and if exists in this tab, this should works.
And... the column variable... I think that "Column" is referring the property from the WorkSheet object, but you need to put object name first with a full stop. In your case: "ws.Columns(1)"
Bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
634726270
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 01:51 PM
I still have an error on the getWorkbook though. I checked and the function is included in the Global Code...
------------------------------
Michelle
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 02:04 PM
------------------------------
Michelle
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 03:15 PM
The "Protected" label is referring about the accessibility of the function or variable. It's hard to explain the meaning of this... but... basically that means that the function is accessible within its Business Object.
If you want to know more, here you have some links from Microsoft
Access Modifiers
Protected
Hope this clarify your questions
Bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
634726270
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 04:03 PM
------------------------------
Michelle
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 05:04 PM
This kind of errors ocurrs when you try to access a list or dictionary and the key does not exists.
Maybe you are getting this error somewhere in the line 14.
Remember that, when we speak about keys and index, we start counting in 0. So... if you have 14 columns, your "lastdatacolumn" need to be 13.
Can you check that?
Bye 🙂
------------------------------
Pablo Sarabia
Architect
Altamira Assets Management
Madrid
634726270
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 05:41 PM
There's an internal dictionary that keeps track of which workbooks are linked to which handles (i.e. Excel instance). Are you trying to work across two different Excel VBOs or are you doing all of this within the standard VBO and just created your own action within it?
Cheers,
------------------------------
Eric Wilson
Director, Integrations and Enablement
Blue Prism Digital Exchange
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 09:46 PM
------------------------------
Michelle
------------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
11-02-22 09:47 PM
In Studio, I have the MS Excel VBO and then I started to create my own with little reusable Excel snippets in a new object, thusly:
Everything was going swimmingly until I had need to add a Code action to one of the pages in my object (the code was to clear data from a number of columns). I added the code and got the messages about protection levels as above.
With Pablo's help, I then copied the relevant 'protected' parts of the Excel VBO to the Global Code tab of my object Initialise page... I had a number of new issues after that, but rather than go into them just yet - should I just create my custom bit of code within the Excel VBO? Are you allowed to do that?
------------------------------
Michelle
------------------------------
