Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. All I want to do is open a .pdf in Acrobat

All I want to do is open a .pdf in Acrobat

Scheduled Pinned Locked Moved Visual Basic
linuxdebugginghelpquestion
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • O Offline
    O Offline
    oakleaf
    wrote on last edited by
    #1

    So I tried this: Dim objWSH As Object : objWSH = CreateObject("WScript.Shell") Call objWSH.Run("'" & Application.StartupPath & "\help_files\Potato_Traceability_User_Guide.pdf" & "'") 'objWSH = Nothing Which works fine while in debug mode. But when the install is compiled and then installed to c:\Program Files\asdf The file cannot be found. (but other files in the same directory of RTF format can be loaded into a rich text box control?) So I tried: Dim objWSH As Object : objWSH = CreateObject("WScript.Shell") mypath = Application.StartupPath.Replace("\", "\\") mypath = mypath.Replace(" ", "%20") Call objWSH.Run("'" & mypath & "\\help_files\\Potato_Traceability_User_Guide.pdf" & "'") 'objWSH = Nothing and a couple of other variations.... what should have taken 10 minutes, I am now 2 hours on...can someone help or let me know what it is that I am doing wrong?

    O D 2 Replies Last reply
    0
    • O oakleaf

      So I tried this: Dim objWSH As Object : objWSH = CreateObject("WScript.Shell") Call objWSH.Run("'" & Application.StartupPath & "\help_files\Potato_Traceability_User_Guide.pdf" & "'") 'objWSH = Nothing Which works fine while in debug mode. But when the install is compiled and then installed to c:\Program Files\asdf The file cannot be found. (but other files in the same directory of RTF format can be loaded into a rich text box control?) So I tried: Dim objWSH As Object : objWSH = CreateObject("WScript.Shell") mypath = Application.StartupPath.Replace("\", "\\") mypath = mypath.Replace(" ", "%20") Call objWSH.Run("'" & mypath & "\\help_files\\Potato_Traceability_User_Guide.pdf" & "'") 'objWSH = Nothing and a couple of other variations.... what should have taken 10 minutes, I am now 2 hours on...can someone help or let me know what it is that I am doing wrong?

      O Offline
      O Offline
      Onderack
      wrote on last edited by
      #2

      Try this; MyPath = Application.StartupPath.ToString Shell(MyPath + "\Potato_Traceability_User_Guide.pdf")

      D 1 Reply Last reply
      0
      • O oakleaf

        So I tried this: Dim objWSH As Object : objWSH = CreateObject("WScript.Shell") Call objWSH.Run("'" & Application.StartupPath & "\help_files\Potato_Traceability_User_Guide.pdf" & "'") 'objWSH = Nothing Which works fine while in debug mode. But when the install is compiled and then installed to c:\Program Files\asdf The file cannot be found. (but other files in the same directory of RTF format can be loaded into a rich text box control?) So I tried: Dim objWSH As Object : objWSH = CreateObject("WScript.Shell") mypath = Application.StartupPath.Replace("\", "\\") mypath = mypath.Replace(" ", "%20") Call objWSH.Run("'" & mypath & "\\help_files\\Potato_Traceability_User_Guide.pdf" & "'") 'objWSH = Nothing and a couple of other variations.... what should have taken 10 minutes, I am now 2 hours on...can someone help or let me know what it is that I am doing wrong?

        D Offline
        D Offline
        Dave Kreskowiak
        wrote on last edited by
        #3

        I'm assuming you're using VB.NET, and not VB6. That being said, :omg: :wtf: Why are you starting an outside app using Windows Scripting Host? The Process class gives you much more control and information. Also, path handling is MUCH easier if you use the Path class.

        Imports System.Io
        .
        .
        .
        Dim cmdLine As String = Path.Combine(Application.StartupPath, "\help_files\Potato.pdf")
        Dim newProcess As New Process()
        newProcess.StartInfo.Filename = cmdLine
        newProcess.StartInfo.UseShellExecute = True
        newProcess.Start()

        RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

        O 1 Reply Last reply
        0
        • O Onderack

          Try this; MyPath = Application.StartupPath.ToString Shell(MyPath + "\Potato_Traceability_User_Guide.pdf")

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Onderack wrote:

          Application.StartupPath.ToString

          Why are you calling .ToString on something that is already a String??? And path handling is better left up to the Path class. Concantenating strings together can be problematic. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

          1 Reply Last reply
          0
          • D Dave Kreskowiak

            I'm assuming you're using VB.NET, and not VB6. That being said, :omg: :wtf: Why are you starting an outside app using Windows Scripting Host? The Process class gives you much more control and information. Also, path handling is MUCH easier if you use the Path class.

            Imports System.Io
            .
            .
            .
            Dim cmdLine As String = Path.Combine(Application.StartupPath, "\help_files\Potato.pdf")
            Dim newProcess As New Process()
            newProcess.StartInfo.Filename = cmdLine
            newProcess.StartInfo.UseShellExecute = True
            newProcess.Start()

            RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

            O Offline
            O Offline
            oakleaf
            wrote on last edited by
            #5

            I was basically trying anything at that point. Yes, VB.net 2003... The code I was using was something that I had jotted down somewhere...sometime ago.. So I used the code you provided with one exception. Dim newProcess As New Process newProcess.StartInfo.FileName = Application.StartupPath & "\help_files\Potato_Traceability_User_Guide.pdf" newProcess.StartInfo.UseShellExecute = True newProcess.Start() The Path.Combine(Application.StartupPath, "\help_files\Potato_Traceability_User_Guide.pdf") did not seem to work. It only sent "\help_files\Potato_Traceability_User_Guide.pdf" ? Thanks.

            D 1 Reply Last reply
            0
            • O oakleaf

              I was basically trying anything at that point. Yes, VB.net 2003... The code I was using was something that I had jotted down somewhere...sometime ago.. So I used the code you provided with one exception. Dim newProcess As New Process newProcess.StartInfo.FileName = Application.StartupPath & "\help_files\Potato_Traceability_User_Guide.pdf" newProcess.StartInfo.UseShellExecute = True newProcess.Start() The Path.Combine(Application.StartupPath, "\help_files\Potato_Traceability_User_Guide.pdf") did not seem to work. It only sent "\help_files\Potato_Traceability_User_Guide.pdf" ? Thanks.

              D Offline
              D Offline
              Dave Kreskowiak
              wrote on last edited by
              #6

              Actually, it should be

              Dim filePath As String
              filePath = Path.Combine(Application.StartupPath, "help_files")
              filePath = Path.Combine(filePath, "Potato_Traceability_User_Guide.pdf")

              This is, of course, assuming that help_files is a subdirectory of the StartupPath. Use Debug.WriteLine statements to figure out what StartUp path is returning. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups