Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Visual Basic 2005 Basics If you are new to Visual Basic programming with version 2005, this is the place to start your questions. For questions about the book: Beginning Visual Basic 2005 by Thearon Willis and Bryan Newsome, ISBN: 0-7645-7401-9 please, use this forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Visual Basic 2005 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 27th, 2007, 03:51 PM
Authorized User
Points: 111, Level: 2
Points: 111, Level: 2 Points: 111, Level: 2 Points: 111, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default Open PDF From Form

I want to include a directory that contains PDF files with my program.
I would like the user to be able to click on the name of the PDF File in a Windows Form and have the PDF open in the free Adobe Reader.

Anyone ever done this?

George

 
Old February 27th, 2007, 04:07 PM
Authorized User
 
Join Date: Nov 2006
Location: , , USA.
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

Add an OpenFileDialog control to the code below. I don't want to do all of the work for you.

    Private Sub subLoadPDFFile()
        Try
            Dim Process As New Process
            With Process
                .StartInfo.FileName = "yourPDFName.pdf"
                .Start()
            End With
        Catch ex As Exception
            '* Error code if Adobe not installed, file not found,etc.
        End Try
    End Sub




Best Regards,
Earl Francis
 
Old February 28th, 2007, 02:26 PM
Authorized User
Points: 111, Level: 2
Points: 111, Level: 2 Points: 111, Level: 2 Points: 111, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2005
Location: , , .
Posts: 22
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Earl:

Boy, that was exactly what I needed to point me in the right direction. Had never run across "New Process" before. This is an amazing language. I truly believe you can do anything you can think of, and quite easily at that.

Again thanks for the help, greatly appreciated.
George Race
Race Consulting

Here is my final code to display a PDF File from a Form:

 Private Sub TextBox1_Click(ByVal sender As Object, _
    ByVal e As System.EventArgs) Handles TextBox1.Click

        'Routine To Read PDF File From VB 2005 Form
        'NOTE: Start by making a TextBox on the form. This routine is started with the
        'click event of the text box. Insert into the TextBox "Tag" parameter the full
        'path and file name of the file to open.

        'Let's setup a variables
        Dim MyPDFFilePathAndName As String

        'Get the File Path and File Name From the TextBox Tag Field
        MyPDFFilePathAndName = Me.TextBox1.Tag.ToString

        'Routine to open the PDF file and catch any errors.
        Try
            Dim process As New Process
            With process
                .StartInfo.FileName = MyPDFFilePathAndName
                .Start()
            End With
        Catch ex As Exception
            MsgBox("There is a problem!" & vbCrLf & ex.Message, 16, ("MY KIT AIRPLANE"))
        Finally
            Beep()
        End Try
    End Sub


 
Old February 28th, 2007, 02:31 PM
Authorized User
 
Join Date: Nov 2006
Location: , , USA.
Posts: 87
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to ef1196
Default

You are quite welcome.



Best Regards,
Earl Francis




Similar Threads
Thread Thread Starter Forum Replies Last Post
Pdf files doesn't open Ciupaz BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 2 September 11th, 2008 04:36 PM
Open PDF within vb6 Jade08 VB How-To 6 May 14th, 2008 10:50 AM
Open Form, run query, open form Grafixx01 Access 7 April 26th, 2007 11:32 AM
open a pdf file viren_balaut J2EE 0 January 26th, 2004 10:50 PM
open a pdf file viren_balaut Servlets 0 January 24th, 2004 01:03 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.