Opening Non-Window Apps

E

elyse

Hi,

I have created a combox object and would like for a user to be able to open
an Adobe PDF file when a selection in the combox is changed. Can I use
AppActivate or do I need to use a differnet method?

So far, I've used this, but it doesn't work

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim MyAppID, ReturnValue

MyAppID = Shell("D:\Adobe_Designer_Forms\deluser.pdf", 1)

AppActivate MyAppID

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
 
B

BruceS

Elyse,

In the OnChange event of the combo box, set the hyperlink address property
of the button to the document you want opened, e.g.

me.Command89.HyperlinkAddress = "C:\OurDocuments\mypdf.pdf"

When the button is clicked, Windows will open the document using the program
defined by the file type or extension. You don't need the shell command.

Bruce
 
E

elyse

Hi BruceS

When I click on the button(Command0), Adobe launches then quickly closes.
I've set the following properties. Maybe I've done something wrong.

Command0 (Button) - Hyperlink Address = (form1.Combo1)

Combo1(OnChange) =

Private Sub Combo1_Change()

If Me.Combo1.Value = "del user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\deluser.pdf"
ElseIf Me.Combo1.Value = "chang user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\disqual.pdf"

End If

End Sub
 
B

BruceS

Elyse,

I tried it here, using a pdf document on my desktop as the target address,
and it worked fine, opening the document with Adobe Reader 7 and leaving it
open. Assuming that the document that you are opening is a normal pdf, and
not some kind of template, I don't know why it's closing immediately.

Your syntax below seemed a little strange, though. In VBA I'd code it as:

Private Sub Combo1_AfterUpdate() 'Use AfterUpdate versus OnChange
Dim myStr as String

Select Case Me![Combo1]
Case "del user":
myStr = "D:\Adobe_Designer_Forms\deluser.pdf"
Case "chang user":
myStr = "D:\Adobe_Designer_Forms\disqual.pdf"
'Enter any other documents as case statements with proper path to
file.
End Select

'Remove the comment below to display the file path so that you can verify it.
' MsgBox myStr

Me.Command1.HyperlinkAddress = myStr

End Sub

It's not necessary to have any code attached to the button.

If you have the file names as a column in the RecordSourcefor the combo box
(what I'd do for easer maintenance), you can use the following instead of the
Select Case:

Private Sub Combo1_AfterUpdate()

Me.Command1.HyperlinkAddress = Combo1.Column (2)
'change the '2' to represent the column with the path to the file.

End Sub

HTH,
Bruce
 
E

elyse

Thanks BruceS

By the way, how many levels deep can a Case statement be? I will have about
15-20 files for staters with plans for future growth. I'm using the combo
box as a menu, so that endusers may select from a list rather than going
directy to the server to hunt for a form.

Thanks
--
Elyse


BruceS said:
Elyse,

I tried it here, using a pdf document on my desktop as the target address,
and it worked fine, opening the document with Adobe Reader 7 and leaving it
open. Assuming that the document that you are opening is a normal pdf, and
not some kind of template, I don't know why it's closing immediately.

Your syntax below seemed a little strange, though. In VBA I'd code it as:

Private Sub Combo1_AfterUpdate() 'Use AfterUpdate versus OnChange
Dim myStr as String

Select Case Me![Combo1]
Case "del user":
myStr = "D:\Adobe_Designer_Forms\deluser.pdf"
Case "chang user":
myStr = "D:\Adobe_Designer_Forms\disqual.pdf"
'Enter any other documents as case statements with proper path to
file.
End Select

'Remove the comment below to display the file path so that you can verify it.
' MsgBox myStr

Me.Command1.HyperlinkAddress = myStr

End Sub

It's not necessary to have any code attached to the button.

If you have the file names as a column in the RecordSourcefor the combo box
(what I'd do for easer maintenance), you can use the following instead of the
Select Case:

Private Sub Combo1_AfterUpdate()

Me.Command1.HyperlinkAddress = Combo1.Column (2)
'change the '2' to represent the column with the path to the file.

End Sub

HTH,
Bruce

elyse said:
Hi BruceS

When I click on the button(Command0), Adobe launches then quickly closes.
I've set the following properties. Maybe I've done something wrong.

Command0 (Button) - Hyperlink Address = (form1.Combo1)

Combo1(OnChange) =

Private Sub Combo1_Change()

If Me.Combo1.Value = "del user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\deluser.pdf"
ElseIf Me.Combo1.Value = "chang user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\disqual.pdf"

End If

End Sub
 
B

BruceS

Elyse,

I'm sure there's some technical limit to the number of "cases", but I've
never needed that many so I don't know what the limit is.

If you have that many forms, you may want to break them down into categories
to make them easier to find. For example, have one combo box for "Document
Type". When user selects the type, you re-query a second combo for "Document
Name". When user picks that, you load the hyperlinkaddress property of the
button.

With that many documents, I definately would use a table to store the
document list. Use a query of that table to populate the combo box list and
include the file name as a column. (You can not show that column, but still
have it there to reference.) This way, you don't need the "Select Case" at
all and you simplify maintenance of the file list.

Bruce

elyse said:
Thanks BruceS

By the way, how many levels deep can a Case statement be? I will have about
15-20 files for staters with plans for future growth. I'm using the combo
box as a menu, so that endusers may select from a list rather than going
directy to the server to hunt for a form.

Thanks
--
Elyse


BruceS said:
Elyse,

I tried it here, using a pdf document on my desktop as the target address,
and it worked fine, opening the document with Adobe Reader 7 and leaving it
open. Assuming that the document that you are opening is a normal pdf, and
not some kind of template, I don't know why it's closing immediately.

Your syntax below seemed a little strange, though. In VBA I'd code it as:

Private Sub Combo1_AfterUpdate() 'Use AfterUpdate versus OnChange
Dim myStr as String

Select Case Me![Combo1]
Case "del user":
myStr = "D:\Adobe_Designer_Forms\deluser.pdf"
Case "chang user":
myStr = "D:\Adobe_Designer_Forms\disqual.pdf"
'Enter any other documents as case statements with proper path to
file.
End Select

'Remove the comment below to display the file path so that you can verify it.
' MsgBox myStr

Me.Command1.HyperlinkAddress = myStr

End Sub

It's not necessary to have any code attached to the button.

If you have the file names as a column in the RecordSourcefor the combo box
(what I'd do for easer maintenance), you can use the following instead of the
Select Case:

Private Sub Combo1_AfterUpdate()

Me.Command1.HyperlinkAddress = Combo1.Column (2)
'change the '2' to represent the column with the path to the file.

End Sub

HTH,
Bruce

elyse said:
Hi BruceS

When I click on the button(Command0), Adobe launches then quickly closes.
I've set the following properties. Maybe I've done something wrong.

Command0 (Button) - Hyperlink Address = (form1.Combo1)

Combo1(OnChange) =

Private Sub Combo1_Change()

If Me.Combo1.Value = "del user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\deluser.pdf"
ElseIf Me.Combo1.Value = "chang user" Then
Me.Command0.HyperlinkAddress = "D:\Adobe_Designer_Forms\disqual.pdf"

End If

End Sub
--
Thanks

Elyse


:

Elyse,

In the OnChange event of the combo box, set the hyperlink address property
of the button to the document you want opened, e.g.

me.Command89.HyperlinkAddress = "C:\OurDocuments\mypdf.pdf"

When the button is clicked, Windows will open the document using the program
defined by the file type or extension. You don't need the shell command.

Bruce

:

Hi,

I have created a combox object and would like for a user to be able to open
an Adobe PDF file when a selection in the combox is changed. Can I use
AppActivate or do I need to use a differnet method?

So far, I've used this, but it doesn't work

Private Sub Command0_Click()
On Error GoTo Err_Command0_Click

Dim MyAppID, ReturnValue

MyAppID = Shell("D:\Adobe_Designer_Forms\deluser.pdf", 1)

AppActivate MyAppID

Exit_Command0_Click:
Exit Sub

Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click

End Sub
 
D

Dirk Goldgar

elyse said:
Hi BruceS

When I click on the button(Command0), Adobe launches then quickly
closes. I've set the following properties. Maybe I've done something
wrong.

That may be due to a bug in Acrobat Reader. ISTR that the initial
release of version 7 had a bug that made it behave that way, and a later
update fixed it. Make sure you have the very latest version.

BTW, you don't have to set a control's HyperlinkAddress property. You
can tell Access to follow the hyperlink directly:

Application.FollowHyperlink "D:\Adobe_Designer_Forms\deluser.pdf"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top