473,542 Members | 13,938 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Open a PDF file

9 New Member
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 9771
Tophurious
13 New Member
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 Recognized Expert Contributor
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
shadowsoulja
9 New Member
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
Tophurious
13 New Member
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 Recognized Expert Contributor
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
shadowsoulja
9 New Member
Thanks for the help guys, much apprieciated
May 31 '07 #7
Shayne82609
3 New Member
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
rpicilli
77 New Member
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
4106
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 JS }, and I like to open only one file every time for all the files. I use "myFunc.js" javascript file for all the files that try to open the...
9
13403
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. But the open() on ifstream only takes char * strings (mbcs?). In old iostreams, I could _wopen() the file, get the filedesc, and call attach() on...
6
55956
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 check if a file is open before deleting it Something like this
2
6117
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 loading images into the picturebox. If you double click the file you want to open in the open file dialog, it somehow interperets one of the clicks...
6
10019
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 the client machine, the file type TIFF is associated with Kodak Imaging Preview. This app works on most client machines. When you click on the link,...
2
4389
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 that extension and use that as my filter criteria for the File Open dialog. Once the user selects a file with that extension (from the File Open...
6
3090
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 highly appreciated
5
11181
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. Ocz, if the file is not exist(e.g. another day), it will creates the file first.
6
34618
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 I would ignore processing that particular file and move to next file. How can I check whether the file is open or not? I tried os.stat and...
0
2645
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 should decompress, open and then delete nearly 400 files. To do so I use "open FILEPT, "zcat $filename|"". In the beginning the script works fine, but...
0
7379
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
1
7312
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7660
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5858
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4875
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3375
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1786
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
941
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
613
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.