PDF opens then closes

  • Thread starter MrMackey via AccessMonster.com
  • Start date
M

MrMackey via AccessMonster.com

When a control on a continous form is clicked, the followhyperlink does not
let the PDF file stay open. I have researched this online in various areas
including microsoft with no luck.

If the pdf link is hard coded into a label's "Hyperlink Address" any user can
open the pdf with no problem, so it appears there are no security issues nor
corrupted PDF files.

Now since I want it to be dynamic on a continous form I have tried both the
followhyperlink and the other option of adding a button and setting the
Hyperlink Address and it works great on all that have a PC no matter the
Adobe version they have. Anyone on a citrix (thin client) can however never
get the pdf do stay open no matter their version.

Since there is a mix of PC and thin clients with different network paths I
can't use a shell command as the path to the .exe is never consistant. There
are also sequrity issues with that approach that makes it not be an option
for me.

'Button sample code:
Private Sub Command20_Click()
Me.Command20.HyperlinkAddress = Me.Path
End Sub

'TextField sample code:
Private Sub anyTF_Click()
Application.FollowHyperlink Me.Path
'or
'Application.FollowHyperlink Me.Path,,True (same result)
End Sub

Microsoft did mention something about the Jet 4.0 driver having issues with
certain VB functions.

Does anyone have a solution?

Please Help! M'kaY?

Mr. Mackey
 
D

Daniel Pineault

What version of access? What version of acrobat? ...

There is a known issue if you are using Acrobat 6. Simply perform/install
all the updates and the problem will most probably go away.

I had this very issue, using Citrix, and once I performed the update and
ensured I was up-to-date everything worked fine.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
M

MrMackey via AccessMonster.com

Daniel said:
What version of access? What version of acrobat? ...

Access 2003 - The Adobe Acrobat version has no impact. Typically the Citrix
users have 7.0 but there are PC users with 7.0 too that have no problem.I'm
personally on 8.0 on a PC and was very surprised to see this. This problem
has been reported in many posts in many forums and there does not seem to be
a one answer to this. Maybe it is just one of those Microsoft bugs that can't
be fixed by coding?

Note that if the URL is hardcoded into a label on the non continous part of
the form then there is no operational problem for anyone no matter PC/Citrix.

If you have any idea I'd be very greatful.

Mr.Mackey
 
D

Daniel Pineault

Instead of using the FollowHyperlink method you could try the following code.
It used to be accessible at

http://www.pacificdb.com.au/MVP/Code/ExeFile.htm

but seems to have disapeared? Anywho, plug this into a module and then use
it to open the pdf and see if it doesn't resolve your problem.

Public Const SW_HIDE = 0
Public Const SW_MINIMIZE = 6
Public Const SW_RESTORE = 9
Public Const SW_SHOW = 5
Public Const SW_SHOWMAXIMIZED = 3
Public Const SW_SHOWMINIMIZED = 2
Public Const SW_SHOWMINNOACTIVE = 7
Public Const SW_SHOWNA = 8
Public Const SW_SHOWNOACTIVATE = 4
Public Const SW_SHOWNORMAL = 1

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As
String, _
ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

Public Sub ExecuteFile(sFileName As String, sAction As String)
Dim vReturn As Long
'sAction can be either "Open" or "Print".

If ShellExecute(Access.hWndAccessApp, sAction, sFileName, vbNullString,
"", SW_SHOWNORMAL) < 33 Then
DoCmd.Beep
MsgBox "File not found."
End If
End Sub
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
M

MrMackey via AccessMonster.com

Thanks for the reply but there must be a better way than using DLL files for
such a "simple" thing as just opening a file from Access.

PacificDB.com probably took this code down for a reason as there was a
security vulnerability for WinXP and MS Server 2003 exploited in shell32.dll
and MS had to release a patch for it.

I much appreciate the effort, but I'm looking for a solution not involving
systrem shell calls nor referencing any of Windows important files. It needs
to be independent of Windows version or PC/Thin Client.

Mr. Mackey
 
T

Tony Toews [MVP]

MrMackey via AccessMonster.com said:
Thanks for the reply but there must be a better way than using DLL files for
such a "simple" thing as just opening a file from Access.

I think you can do something with Hyperlink function.
PacificDB.com probably took this code down for a reason as there was a
security vulnerability for WinXP and MS Server 2003 exploited in shell32.dll
and MS had to release a patch for it.

Possibly but using ShellExecute is very standard code. I use that
myself in lots of places.
I much appreciate the effort, but I'm looking for a solution not involving
systrem shell calls nor referencing any of Windows important files. It needs
to be independent of Windows version or PC/Thin Client.

ShellExecute is independent of Windows version and PC/Thin Client.
Well, ok, looks like it didn't exist in Windows 3.1 or earlier.

Minimum operating systems - Windows NT 3.1, Windows 95
http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
M

MrMackey via AccessMonster.com

Thanks,

The code provided by Mr. Pineault is not compiling as posted, so I did not
even bother testing it. Our thin client users are pretty much locked down to
only being able to do basic tasks. Will that still work for them? I'm using a
network path as being passed in that should not matter should it?

such as:
//something/somethingelse/filefolder/filename.pdf

I found an interesting note on Adobe about their 7.0 version having bugs :
http://kb.adobe.com/selfservice/viewContent.do?externalId=331197&sliceId=2

Now as I tested the followlink method on a PC that also had 7.0... it worked
fine. (!!! ??? !!!) It also works fine for all thin clients on any
label/button where the hyperlinkaddress is static and set before the form is
opened. I tried passing the url to any such controls on popups too and it
seems as soon as the URL is not there BEFORE runtime it will keep having this
open/close errror. How would this shell execute be any different? I also
tried having Adobe open when the open command is given but it remains blank.

This is driving me nuts... MkaY...

Mr. Mackey
 
M

MrMackey via AccessMonster.com

PROBLEM SOLVED!!!

I found this online:
http://groups.google.com.hk/group/m...mming/msg/97de0c40dfba3dbc?hl=en&lr=&ie=UTF-8


Private Const SW_SHOWMAXIMIZED = 3


Private Declare Function ShellExecute _
Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, _
ByVal lpOperation As String, _
ByVal lpFile As String, _
ByVal lpParameters As String, _
ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long


Public Function gbOpenFile(rsPath As String) As Boolean
If ShellExecute(0, "open", rsPath & vbNullChar, _
vbNullString, vbNullString, SW_SHOWMAXIMIZED) > 32 Then
gbOpenFile = True
End If
End Function

It works!!! Paste it into a new module and call the gbOpenFile
(yourURLgoesHere)

Thanks Mr. Pineault and Mr. Towes for helping!
 
T

Tony Toews [MVP]

MrMackey via AccessMonster.com said:
The code provided by Mr. Pineault is not compiling as posted, so I did not
even bother testing it. Our thin client users are pretty much locked down to
only being able to do basic tasks. Will that still work for them?

Not sure what you mean by thin client. Or do you mean they use a
Terminal Server system? If so that works.
I'm using a
network path as being passed in that should not matter should it?

That works too.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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