How to open a excel file

vrk1219

Registered User.
Local time
Tomorrow, 01:15
Joined
Mar 13, 2009
Messages
45
Hi,
This question may be silly, but I want to open a file under a path, from a form. (on click of a button)

Thanks,
RK Veluvali
 
You can set the hyperlink path of the button to the path of the Excel file.

If you want the button to open a file from a path typed inside a textbox you can use the following code:

Dim file As String
If Not IsNull(FilepathFIELD) Then
file = FilepathFIELD
Me.btnOpen.HyperlinkAddress = file
Else
Me.btnOpen.HyperlinkAddress = ""
End If
 
Or a simpler method in the Button's Click event:

Code:
If Len(Me.YourTextBoxNameHere & "") > 0 Then
   FollowHyperLink Me.YourTextBoxNameHere
End If
 
You can set the hyperlink path of the button to the path of the Excel file.

If you want the button to open a file from a path typed inside a textbox you can use the following code:

Dim file As String
If Not IsNull(FilepathFIELD) Then
file = FilepathFIELD
Me.btnOpen.HyperlinkAddress = file
Else
Me.btnOpen.HyperlinkAddress = ""
End If

Hi,
Thanks a lot for your reply.
The solution fits fine for me.
But, after I click on the button, I'm getting a message saying "Hydperlinks are harmful....."
Can you tell me, how to disble that dislog?

Thanks
RK Veluvali
 
I have no experience with that error message, it might be a security setting on your computer. You can try:

DoCmd.Setwarnings False

RUN CODE

DoCmd.Setwarnings True

Maybe that will disable the warning message, but I somehow doubt it. Also note that Bob's code does the same thing as mine, but is shorter and more tidy.
 

Users who are viewing this thread

Back
Top Bottom