Help with a command button to open a file

ladivapr

Registered User.
Local time
Today, 20:27
Joined
Jul 15, 2003
Messages
28
I want a command buttom that opens a specific excel file. I dont know how to do this. Most I can do is open the excel application with the command wizard and thats about it. Please help guys! Somebody suggested me this code to put on the onclick field of the buttom:

Application.FollowHyperlink "C:\Documents and Settings\Template.xls", , True, True


But it doesnt seem to work. Help!

diva
 
Your code probably looks like this...
Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

    Dim oApp As Object

    Set oApp = CreateObject("Excel.Application")
    oApp.Visible = True
    'Only XL 97 supports UserControl Property
    On Error Resume Next
    oApp.UserControl = True

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
    
End Sub

it should look somthing like this...
Code:
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

        Application.FollowHyperlink "C:\Documents and Settings\IanM\Desktop\Spec Template.xls", , True, True

Exit_Command1_Click:
    Exit Sub

Err_Command1_Click:
    MsgBox Err.Description
    Resume Exit_Command1_Click
    
End Sub

HTH
 
Last edited:
re

Oh man thanks that works!! Now I wish I can export data from that form to add in that file but I think that will take a whole lot more coding :)
 

Users who are viewing this thread

Back
Top Bottom