Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
VBA open xls as Read-Only?
I open a xls for inserting values from vba. However, I could not get over the
worksheet been openned as Read-Only part. Your help is appriciated! Of cause, I did not come up with the original sample code. By the way, all the samples I found are for opening a new xls then insert data into it. I need to open an existing xls. Here is my code: (m_objExcel is declared as Private m_objExcel As New cExcel) Private Sub Command1_Click() m_objExcel.OpenWorkbook "V:\my.xls", False m_objExcel.StartExcel True 'after this line, I can see the xls, and its title said read-only 'next sub will insert the value, however, I would not be able to save it. m_objExcel.InsertValue "L2", "20" End Sub Here are from class module: Public Function OpenWorkbook(strFileName As String, fReadOnly As Boolean, _ Optional varPassword As Variant) As Excel.Worksheet ' Comments : Opens the named file and associates it with the class ' Parameters: strFileName - full path and name of the file to open ' fReadOnly - True to open readonly If Not IsMissing(varPassword) Then ... Else Set m_objWorkbook = m_objExcel.Workbooks.Open(strFileName, , fReadOnly) End If End Function Public Sub StartExcel(fVisible As Boolean) ' Comments : Starts an instance of Excel ' Parameters: fVisible - True to make Excel visible .... m_objExcel.Visible = fVisible .... End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Open in Read Only | Excel Discussion (Misc queries) | |||
open as read only | Excel Programming | |||
Open as read only Problem | Excel Worksheet Functions | |||
Open as read-only | Excel Worksheet Functions | |||
Open File Read Only | Excel Programming |