cancel
Showing results for 
Search instead for 
Did you mean: 

Excel Read Only Access

PrajjwalRai
Level 5
Hi all
I am trying to write data from an excel file to another excel template using Excel VBO. I am facing an issue related to the access of the template, it's showing an error "Cannot access read-only document ".... .csv". I created the excel template using Create Instance and Create Workbook and then further saving it using Excel VBO.
Any leads on how to resolve this?

------------------------------
Prajjwal Rai
Application Engineer
Schneider Electric Private Limited
------------------------------
1 REPLY 1

ChenglungTsai1
Level 5
The fast way to solve this issue is to create a new action to handle with your read-only excel file.
You can follow the steps below.

1. Go to "Open Workbook" page and duplicate it.

2. Go to "Open Workbook - Copy" page and open the "Open Workbook" code stage.

3. Replace the code by this code below and rename this stage and page

Dim wb as Object = GetInstance(handle).Workbooks.Open(FileName:=filename,ReadOnly:=True)
name = wb.Name
wb.Activate()

4. That's all. And you can public this page and use it.

Or you can add any parameters if you need them to do some excel manipulation.

Example

Dim wb as Object = GetInstance(handle).Workbooks.Open(filename,UpdateLinks:=updatelinks,ReadOnly:=readonly1,Password:=password,WriteResPassword:=writerespassword,IgnoreReadOnlyRecommended:=True)
name = wb.Name
wb.Activate()

--
If my memory is correct, I remember in the old MS Excel VBO version is using "GetInstance(handle).Workbooks.Open" method to open excel file.
But I don't know why BP changes this way to open excel file in new version. (It uses the private function called invoke which is defined by global code to open excel file now. I don't know how to pass more than one parameter to this method.)


------------------------------
Chenglung Tsai
Consultant
Avanade
------------------------------