Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / September 2005

Tip: Looking for answers? Try searching our database.

Run Application

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Alan - 28 Sep 2005 23:54 GMT
Hope some one can help

I have a command button on a form with the following code on it

Private Sub Command81_Click()
On Error GoTo Err_Command81_Click

   Dim stAppName As String

   stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe
d:\01.pdf"
   Call Shell(stAppName, 1)

Exit_Command81_Click:
   Exit Sub

Err_Command81_Click:
   MsgBox Err.Description
   Resume Exit_Command81_Click

End Sub

What I would like it to do is to get the path and file name from a text
field on the same form as the command button.  How do I insert a reference
to this text field after the Acrobat.exe so it opens the file when it loads.
Have tried various options putting the text field name in brackets i.e.
[PathToFile] after the Acrobat.exe but it cannot find the file.   Any help
or pointers would be great.   Or is there a better way to open a Acrobat PDF
file from a command button in Access.
Allan Murphy - 29 Sep 2005 01:42 GMT
Alan

Try this
Add a text box to your form call it file_path

Enter the full path and filename
e.g. d:\downloads\47s.pdf

Private Sub Command81_Click()
On Error GoTo Err_Command81_Click

Dim stAppName As String
Dim file_path as string

file_path = me!file_path

stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe " &
file_path

Call Shell(stAppName, 1)

Exit_Command81_Click:
    Exit Sub

Err_Command81_Click:
    MsgBox Err.Description
   Resume Exit_Command81_Click

End Sub

Signature

Allan Murphy
Email: allanmurphy@unwired.com.au

> Hope some one can help
>
[quoted text clipped - 25 lines]
> or pointers would be great.   Or is there a better way to open a Acrobat PDF
> file from a command button in Access.
Van T. Dinh - 29 Sep 2005 08:30 GMT
Try:

Shell Chr$(34) & strAppName & Chr$(34) & " " & _
   Chr$(34) & Me.PathToFileTextBox & Chr$(34), vbNormalFocus

--
HTH
Van T. Dinh
MVP (Access)

> Hope some one can help
>
[quoted text clipped - 25 lines]
> or pointers would be great.   Or is there a better way to open a Acrobat PDF
> file from a command button in Access.
Alan - 29 Sep 2005 21:13 GMT
Thanks for the help.  One little extra please.

Could the code be adjusted so that it checks the [path] text box to see if
there is a Path to the PDF file and if not it brings up a message box saying
"NO Image Found" and then the action is cancelled.  Below is the code I have
so far:   If I click my command button with no path in the path text box
then I get an error message.  Invalid Use Of Null

Private Sub Command81_Click()
On Error GoTo Err_Command81_Click

   Dim stAppName As String
   Dim Tpath As String

   Tpath = Me!path

   stAppName = "C:\Program Files\Adobe\Acrobat 7.0\Acrobat\Acrobat.exe " &
Tpath
   Call Shell(stAppName, 1)

Exit_Command81_Click:
   Exit Sub

Err_Command81_Click:
   MsgBox Err.Description
   Resume Exit_Command81_Click

End Sub

> Try:
>
[quoted text clipped - 39 lines]
> PDF
>> file from a command button in Access.
Van T. Dinh - 30 Sep 2005 06:03 GMT
Check Access VB Hel on thr Dir() function.

--
HTH
Van T. Dinh
MVP (Access)

> Thanks for the help.  One little extra please.
>
[quoted text clipped - 24 lines]
>
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.