Tuesday, 5 March 2013

Open Excel File in VB6

Private Sub Command1_Click()

On Error GoTo ErrHandler
    Dim xlApp As Object
    Dim xlWB As Object
    
    Set xlApp = CreateObject("Excel.Application")
    xlApp.Visible = True
    
    Set xlWB = xlApp.Workbooks.Open("c:\Counselor.xls")
    Exit Sub
    
ErrHandler:
    MsgBox "There is a problem opening that workbook!", vbCritical, "Error!"
  End Sub 

http://www.mrexcel.com/forum/general-excel-discussion-other-questions/261062-simple-vb6-code-open-excel-file.html

No comments:

Post a Comment