Open PDF File

Having trouble opening a valid PDF file

Page 1 of 1

3 Replies - 4778 Views - Last Post: 04 January 2010 - 03:06 PM Rate Topic: -----

#1 ZRonZ  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 206
  • Joined: 09-January 09

Open PDF File

Posted 28 December 2009 - 02:25 PM

I'm working on an electronic MSDS system where (eventually) the user will select the product and click a button to open the MSDS. For testing purposes I included the .initialdirectory, .filename and .filter in code. The following opens the OpenFileDialog with the desired directory showing with the only the specific file showing and the file name is in the File Name box. However, the file doesn't open when selected in the OpenFileDialog. No exceptions are being thrown. I stepped through it and there are no logic errors. The only thing I'm thinking is that the .filename and .filter can't be selected at run time. Any insight?

	Private Sub btnGetMSDS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetMSDS.Click
		Dim ResponseDialogResult As DialogResult

		With OpenFileDialog1
			.InitialDirectory = "J:\MSDS Copies"
			.FileName = "DP-E61BC0700.pdf"
			.Filter = "PDF Files|DP-E61BC0700.pdf"

			ResponseDialogResult = .ShowDialog()
		End With

	End Sub



Is This A Good Question/Topic? 0
  • +

#3 Sethro117  Icon User is offline

  • Still the sexiest mofo.
  • member icon

Reputation: 236
  • View blog
  • Posts: 2,378
  • Joined: 14-January 09

Re: Open PDF File

Posted 28 December 2009 - 03:43 PM

Try adding Process.Start(OpenFileDialog1.FileName)

Its not going to open unless you tell it to.
Was This Post Helpful? 1
  • +
  • -

#4 ZRonZ  Icon User is offline

  • D.I.C Head

Reputation: 28
  • View blog
  • Posts: 206
  • Joined: 09-January 09

Re: Open PDF File

Posted 28 December 2009 - 07:02 PM

		Dim OpenFileDialog1 As New OpenFileDialog()
		OpenFileDialog1.Title = "Select a PDF file to Import"
		OpenFileDialog1.Multiselect = False
		OpenFileDialog1.FileName = "J:\MSDS Copies\F63BC72_MSDS_English.pdf"
		Process.Start(OpenFileDialog1.FileName)



Here's the finished working code for reference to others having the same "opportunity". This opens the desired pdf file in Adobe Reader without having to select the file. And my VB instructor with a lot of experience said this can't be done!

Thanks Sethro117 for the help.
Was This Post Helpful? 0
  • +
  • -

#5 Jack Eagles1  Icon User is offline

  • Pugnacious Penguin (inspired by no2pencil)
  • member icon

Reputation: 183
  • View blog
  • Posts: 1,152
  • Joined: 10-December 08

Re: Open PDF File

Posted 04 January 2010 - 03:06 PM

You could Just use a .pdf control in your form. Just go to select items in the toolbox, and there should be one name AxAcroPdf or something like that.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1