how to open an excel file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • meditcakepbgt
    New Member
    • Sep 2006
    • 8

    how to open an excel file?

    hi guys..

    another question..
    i have a button in a predesigned form..
    what i will do is to open an specific excel file automatically after i pressed this button

    without arranging the hyperlink property of the button
    how can i do it?
    what is the code..
  • Tanis
    New Member
    • Mar 2006
    • 143

    #2
    Couple of ways, using automation, or using the shell command. Here is both ways.

    Private Sub cmdOpenExcelFil e_Click()
    Dim stAppName As String

    stAppName = "C:\Program Files\Microsoft Office\Office11 \excel.exe PathName.xls"

    Call Shell(stAppName , 1)

    End Sub


    Private Sub OpenXLWithAutom ation_Click()
    Dim appExcel As Excel.Applicati on
    Dim wkb As Excel.Workbook
    Dim strFile As String
    Set appExcel = New Excel.Applicati on
    strFile = "PathName.x ls"
    Set wkb = appExcel.Workbo oks.Open(strFil e)
    appExcel.Visibl e = True 'Do something with worksheet
    Set wkb = Nothing
    Set appExcel = Nothing
    End Sub

    Comment

    • meditcakepbgt
      New Member
      • Sep 2006
      • 8

      #3
      great it works..

      do you have any idea how can we open the excel file which cannot be editted by the viewer.. how to make the file which we viewed is not editable (read only)?

      Thank you
      mdtckpbgt

      Comment

      • Tanis
        New Member
        • Mar 2006
        • 143

        #4
        You will have to do that in Excel. Have a look at protection in the Excel help. Have you thought about linking?

        Comment

        Working...