Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VB6 : open excel file in readonly mode

Status
Not open for further replies.

asihuay

Technical User
Mar 23, 2003
4
0
0
TR
Hi.
I need vb6 code in order to open excel file in readonly mode.
My needs are create an vb6 exe file.
I have very good know in vba but vb6 I am beguinner.
Thanks in advance.
asihuay
 
Dear asihuay

use the following code in general declaration

Dim m_objExcel As Excel.Application
Dim m_objWorkbook As Excel.Workbook

place a command button on form and cpation is OPEN
and on command button click paste the bellow code

Set m_objExcel = New Excel.Application
m_objExcel.Visible = TRUE

m_objExcel.DisplayAlerts = False
Set m_objWorkbook = m_objExcel.Workbooks.Open("C:\abc.xls", True ,true,,"")

place a command button on form and cpation is Close
and on command button click paste the bellow code

m_objWorkbook.Close SaveChanges:=False
m_objExcel.Quit


regards
KQKMBI
 
option explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' DECLARE EXCEL VARIABLE
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public XLApp As Excel.Application

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' OPEN WORKBOOK
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Sub OpenXL()
Set XLApp = New Excel.Application
XLApp.Workbooks.Open App.Path + "Workbook1.xls", ReadOnly:=True
XLApp.Visible = True
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top