473,396 Members | 1,921 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Problem opening PDF files as a link

I have created a form with a hyperlink which opens a PDF file.

However when you click the link the file opens briefly and shuts down automatically, I have tried opening diffetrent file type and they work fine it is just the PDF that messes up.

For clarification if I open the PDF from explorer it works fine and I have tried several files.

Any suggestions.

Neil
Sep 22 '07 #1
5 2247
missinglinq
3,532 Expert 2GB
You have inadvertently posted your question in the Articles section rather than in the Forum section of our site, so I have moved it across to the Forum for you.

Welcome to TheScripts!

Linq ;0)>
Sep 22 '07 #2
puppydogbuddy
1,923 Expert 1GB
I have created a form with a hyperlink which opens a PDF file.

However when you click the link the file opens briefly and shuts down automatically, I have tried opening diffetrent file type and they work fine it is just the PDF that messes up.

For clarification if I open the PDF from explorer it works fine and I have tried several files.

Any suggestions.

Neil
Neil,

Try using the ShellExecute method. It does not have the limitations that the Shell() function and Application.FollowHyperLink method do.

The following example uses ShellExecute on a button click event:
Expand|Select|Wrap|Line Numbers
  1. Dim strPdfWriterPath As String
  2. Dim strFilePath As String
  3.  
  4. 'Open File
  5. 'strPdfWriterPath is the path to the application object
  6. 'strFilePath is the path to the file you want to open
  7.  
  8. strPdfWriterPath = "C:\Program Files\Adobe\Acrobat 5.0\Acrobat\Acrobat.exe"
  9. strFilePath = Me.FilePath
  10.  
  11. Call Shell(strPdfWriterPath & " " & strFilePath, vbMaximizedFocus)
Sep 22 '07 #3
many thanks puppydog, it worked
Sep 23 '07 #4
zigzag
2
Neil,

Just to add, the problem you were seeing originaly is due to an issue with Acrobat reader. If you check you will probably find that it is version 7.0.0.
If you get the latest version it will cure the problem.

Garry
Sep 23 '07 #5
Neil,

Just to add, the problem you were seeing originaly is due to an issue with Acrobat reader. If you check you will probably find that it is version 7.0.0.
If you get the latest version it will cure the problem.

Garry
Just to add to this further, I had the same issue; this only occurred on machines that had both Adobe Acrobat and Adobe Reader installed, fairly common in our setup. I had to explicitly open the doc in reader. here's a section of the code I used in case it's of use to others, I know it took me days to find the answer on the web!

Expand|Select|Wrap|Line Numbers
  1.     fCloseApp ("AdobeAcrobat")
  2.     Set fs = CreateObject("Scripting.FileSystemObject")
  3.     MyCaseID = Me.CaseID
  4.  
  5.     'prints case documents where checkboxes are ticked
  6.     If Me.PrintDocs = -1 Then
  7.         Set MyControl = Forms!frmPatients.Form!sfrmCases.Form!sfrmDocuments
  8.         MyControl.SetFocus
  9.         Set ObjRecordSet = MyControl.Form.RecordsetClone
  10.         ObjRecordSet.MoveFirst
  11.         Do Until ObjRecordSet.EOF
  12.             If ObjRecordSet.Print = -1 Then
  13.                 MySourceDir = DocPathWay
  14.                 MyFileName = ObjRecordSet.FileName
  15.                 StrOutputFile = MySourceDir & MyFileName
  16.                 strAcroPath = "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe"
  17.                     If fs.FileExists(StrOutputFile) = True Then
  18.                         strAcroPath = strAcroPath & " /t " & StrOutputFile
  19.                         dwReturn = Shell(strAcroPath, vbMinimizedNoFocus)
  20.                         DoCmd.SetWarnings False
  21.                         MySQL = "INSERT INTO tblPrintHistory (EventType, UserID, CaseID, Document, PrintDate) " & _
  22.                         "SELECT 1 as EventType, """ & fosEmpID & """ as UserID, """ & MyCaseID & """ as CaseID, " & _
  23.                         """" & stDocName & """ as document, Now() as PrintDate;"
  24.                         DoCmd.RunSQL MySQL
  25.                         DoCmd.SetWarnings True
  26.  
  27.                     Else
  28.                         MsgBox StrOutputFile & " does not exist"
  29.                     End If
  30.             End If
  31.         ObjRecordSet.MoveNext
  32.         Loop
  33.     End If
Sep 25 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Alfons | last post by:
Hello, I have build a program that can do file transferring between a Windows XP computer and a DOS computer via a serial port. The Windows program I have build in C++ with Visual Studio 6.0....
5
by: John Morgan | last post by:
I am using the following link to download a file of about 50k <a target= "_blank" href="http://www.bsecs.org.uk/ExecDocs/documentStore/elfridaWord.doc">open file</a> If I save the file to...
10
by: Don Munroe | last post by:
This one has me stumped. I have three web applications running on two different servers. The first that works fine is hosted by a .Net hosting company. Everyone that uses it has no problems...
2
by: John | last post by:
Hi, I posted this earlier in microsoft.public.dotnet.framework.aspnet, but didn't get a response, so I thought I'd try here. Basically, I'm having a problem opening / downloading csv files...
1
by: lennyw | last post by:
Hi I'm trying to build XMLgawk (latest version 3.1.5 from sourceforge) and I'm getting some make errors. I'm using the tool availbale from Cygwin to do the build (gcc, bash, make). I was able...
11
by: emailus | last post by:
I am webmaster for the domain <www.alpha1.org.au>. Not being an expert in html, I take advantage of my domain Registrant's web building tool, 'Instant Website'. This tool is provided as part of...
9
compman9902
by: compman9902 | last post by:
Hello, and thank toy for reading this post. Thus far, this website has helped me a lot, (I have finally finished my encryptor: "site removed by moderator", go to the downloads link) and I will...
0
by: praveenkhade | last post by:
I am working on asp.net ,C#. The pdf files in the grid are displaying properly. The main prob is that in these pdfs one pdf is the main like an index ,if i open this pdf i can link to rest of...
1
navanova
by: navanova | last post by:
Greetings, I have a problem of opening ms word and excel files on my computer. The files are there for a long time. I use to open and modify them. Suddenly, when i try to open the word files, a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.