Open an Excel workbook as read-only through VB6

I have an application written in VB6 that writes data to a spreadsheet. I use the MS Excel 11.0 object library to create an Excel instance and open a workbook:

Dim xlApp As Excel.Application, remoteBook As Workbook
Set xlApp = New Excel.Application
Set remoteBook = xlApp.Workbooks.Open(sheetName)

In addition to writing to the sheetName book, the program also allows the user to run the book to view cumulative results.

There is a possibility that the user may open the book to view the results while someone is trying to write it. I want the user to record the priority of the sheet. Is there a way to run a read-only view sheet? There is a read-only property of the excel application object, but it (of course) is read-only.

How can I configure my program to write data to a book, even if someone accidentally left a file open on their desk?

+3
source share
3 answers

Just do the following:

Set remoteBook = xlApp.Workbooks.Open( sheetName, , true)

If true, should it be read-only. ReadOnly is the third parameter for this method.

+5
source

I think you can do this with a method Workbook.ChangeFileAccessas described here . Not sure if this will suit your circumstances.

0
source

, :

  • excel
  • Excel

, : , .
,

Set remoteBook = xlApp.Workbooks.Open( sheetName, , true)

100% , .

, , .

?

, , " " " ", " "; , , .

, - .

0

Source: https://habr.com/ru/post/1751080/


All Articles