473,396 Members | 2,068 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.

Open a PDF file

Okay, i dislike using VB but for a certain assignment i must.

I want to have a button open a pdf file, it doesnt need to be in visual basic, i wud prefer it was clicked and then it loaded up in Acrobat.

I have the address of where the file is... and i know that obviously has something to do with it.

slap me if its that easy....


Leon
May 31 '07 #1
9 9742
well you can always use shell commands to open up the file (same commands as say the command window) or you can CreateObject("PDF.PdfCtrl.5") (i think thats right) but the latter will view within your vb program. I think if you just want to open adobe to view a shell command would be easiest
May 31 '07 #2
SammyB
807 Expert 512MB
In .Net, it looks like:
Expand|Select|Wrap|Line Numbers
  1. Dim pRun As System.Diagnostics.Process = New System.Diagnostics.Process
  2. pRun.StartInfo.FileName = "C:\SomePath\TheFile.pdf"
  3. pRun.StartInfo.UseShellExecute = True
  4. pRun.Start()
  5.  
May 31 '07 #3
Im using VB6... not sure if that helps.

im not sure on any of this shell stuff.... you might have to babyfeed it to me until i have something i recognise.

Sorry

Leon
May 31 '07 #4
easy enough

basically its

Shell(pathname, window style)

pathname as string

window style i would recommend either
vbMaximizedFocus -maximize it and focus
vbNormalFocus -open normal and focus
May 31 '07 #5
SammyB
807 Expert 512MB
Im using VB6... not sure if that helps.

im not sure on any of this shell stuff.... you might have to babyfeed it to me until i have something i recognise.

Sorry

Leon
No problem, it's just a one liner, something like this:
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32 C:\Documents and Settings\cheryltest\My Documents\ArcMap.pdf", vbNormalFocus

IE
Shell "ReaderPath DocFileSpec", WindowState
May 31 '07 #6
Thanks for the help guys, much apprieciated
May 31 '07 #7
No problem, it's just a one liner, something like this:
Shell "C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32 C:\Documents and Settings\cheryltest\My Documents\ArcMap.pdf", vbNormalFocus

IE
Shell "ReaderPath DocFileSpec", WindowState

Ok, first please forgive me for being a noobie. I am working on a VB6 program to be included in a business CD. The goal is to burn it and the related .pdf files to a CD to be able to distribute to vendors and clients. Basically a autostart CD menu. VB6 is what I have to work with, not by choice.

The code lines above will open a specific version of A.R. if installed into a specific place. I need one that will open the AcroRd32 file in much more generic fashion. Is there a way to do this, so that no matter what version they have it will open the .pdf file with the "Windows default"?

This is what I have so far. It works if and ONLY if the drive letters are correct.

Private Sub Command1_Click()
Dim RetVal
RetVal = Shell("C:\Program Files\Adobe\Reader 9.0\Reader\acrord32 I:\brochure.pdf")
End Sub

If the drive letters are not right, it obviously wont work, hence the problem.


Thanx.
Nov 18 '08 #8
Hi there

If you're using new version of VB you can type the following


Process.Start("c:\mypdffile.pdf")

More easy then that just if you double click over the file...
Nov 19 '08 #9
I know that your project isn't being worked on any more. But the script to get the drive letter in VB looks like this:
Expand|Select|Wrap|Line Numbers
  1. Public Function OpticalDrive()
  2.         Dim CDRom As String = ""
  3.  
  4.         For Each drive_info As DriveInfo In DriveInfo.GetDrives()
  5.             If (drive_info.DriveType() = DriveType.CDRom) Then
  6.                 If (drive_info.IsReady = True) Then
  7.                     CDRom = drive_info.Name
  8.                 End If
  9.             End If
  10.         Next drive_info
  11.  
  12.         Return CDRom
  13.     End Function
  14.  
Oct 21 '10 #10

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

Similar topics

1
by: yanivmad | last post by:
hi I like to ask if there any option to control the html files?!? I have some HTML files at my web site that use one "Help.htm" file for all the pages {I use the "window.open(.... " option at...
9
by: Charles F McDevitt | last post by:
I'm trying to upgrade some old code that used old iostreams. At one place in the code, I have a path/filename in a wchar_t string (unicode utf-16). I need to open an ifstream to that file. ...
6
by: Dino Buljubasic | last post by:
My application creates some temporary files that are deleted when my application terminates. However, if a temp file is open, it will not be deleted and application will crash. How can I...
2
by: Mattbooty | last post by:
Hello, Not sure if anyone else has seen this bug, but I have a form where the entire form is covered with a picturebox. The picturebox has a mouseup event. I also have an open file dialog for...
6
by: qysbc | last post by:
I have a web page and there is a link to open a TIFF file. The way I do it is to have the server code open a binary stream, set the content type to "image/tiff" and call Response.BinaryWrite. On...
2
by: OutdoorGuy | last post by:
Greetings, I have a "newbie" question in relation to opening files from C#. I have a Windows form where I allow the user to type in a file extension in a text box (e.g., "xls"). I then take...
6
by: Moumen VB.NET 2003/2005 Developer | last post by:
How can I detect if a file sitting on a network drive is still open by another application? This application resides on another machine on the network? I am using VB.NET 2003 Your help is...
5
by: Ryan Liu | last post by:
Hi, Both way works, I'd just ask some experts which way is better? My application creates a log file daily. Now each time when I write a log, I will open the file and append to the end....
6
by: Ros | last post by:
There are 10 files in the folder. I wish to process all the files one by one. But if the files are open or some processing is going on them then I do not want to disturb that process. In that case...
0
by: Ofelia | last post by:
Hi, I'm new to this forum and to Perl language but I would like to ask for your help. I'm working in Linux and the files I need to process are in the format “file.gz”. I created a script which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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:
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.