Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Open in Read Only Barb W Excel Discussion (Misc queries) 6 October 21st 08 07:03 PM
open as read only Newbie80[_11_] Excel Programming 1 August 10th 05 02:28 PM
Open as read only Problem Dave Excel Worksheet Functions 0 July 26th 05 01:38 PM
Open as read-only Dave Excel Worksheet Functions 0 July 26th 05 01:21 PM
Open File Read Only Chris Excel Programming 1 September 23rd 04 12:11 AM


All times are GMT +1. The time now is 09:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"