Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

opening pdf`s

Hiya i want to open pdf via VB.
i have the code were i can open certin files if i use this code :
Private Sub Command2_Click()
Dim RetVal
RetVal = Shell("C:Program FilesAdobeAcrobat 7.0ReaderAcroRd32.exe d:Till Manuals120.pdf", vbMaximizedFocus)
End Sub

But what i want to do is not have to type the location of the file in but for the code to pick it up from a txt box were the location is got from a database

Comments

  • the walrusthe walrus Posts: 249Member
    you'll want to do something like this

    [code]Private Sub Command2_Click()
    Dim RetVal
    RetVal = Shell("C:Program FilesAdobeAcrobat 7.0ReaderAcroRd32.exe [blue]" & Text1.Text[/blue], vbMaximizedFocus)
    End Sub [/code]

    to open the location that's in [italic]Text1.Text[/italic]
  • darthmilldarthmill Posts: 7Member
    : you'll want to do something like this
    :
    : [code]Private Sub Command2_Click()
    : Dim RetVal
    : RetVal = Shell("C:Program FilesAdobeAcrobat 7.0ReaderAcroRd32.exe [blue]" & Text1.Text[/blue], vbMaximizedFocus)
    : End Sub [/code]
    :
    : to open the location that's in [italic]Text1.Text[/italic]
    :
    Thanks it worked
  • dokken2dokken2 Posts: 532Member
    : you'll want to do something like this
    :
    : [code]Private Sub Command2_Click()
    : Dim RetVal
    : RetVal = Shell("C:Program FilesAdobeAcrobat 7.0ReaderAcroRd32.exe [blue]" & Text1.Text[/blue], vbMaximizedFocus)
    : End Sub [/code]
    :
    : to open the location that's in [italic]Text1.Text[/italic]
    :

    One warning, you want to be careful in 'hard-coding' and assuming the path for where acrobat [or any windows program] is installed.
    What happens if the user did not install acrobat in the default Program files folder? By checking the registry you will be sure of the install path.

  • the walrusthe walrus Posts: 249Member
    : : you'll want to do something like this
    : :
    : : [code]Private Sub Command2_Click()
    : : Dim RetVal
    : : RetVal = Shell("C:Program FilesAdobeAcrobat 7.0ReaderAcroRd32.exe [blue]" & Text1.Text[/blue], vbMaximizedFocus)
    : : End Sub [/code]
    : :
    : : to open the location that's in [italic]Text1.Text[/italic]
    : :
    :
    : One warning, you want to be careful in 'hard-coding' and assuming the path for where acrobat [or any windows program] is installed.
    : What happens if the user did not install acrobat in the default Program files folder? By checking the registry you will be sure of the install path.
    :
    :

    well the best way to do it would be to use the ShellExecute API to launch to pdf. that way, whichever default application is set to be a pdf reader will open it, but the OP didn't sound like he was ready to get into API yet. it made more sense just to show him how to concatenate strings.
  • darthmilldarthmill Posts: 7Member
    : : : you'll want to do something like this
    : : :
    : : : [code]Private Sub Command2_Click()
    : : : Dim RetVal
    : : : RetVal = Shell("C:Program FilesAdobeAcrobat 7.0ReaderAcroRd32.exe [blue]" & Text1.Text[/blue], vbMaximizedFocus)
    : : : End Sub [/code]
    : : :
    : : : to open the location that's in [italic]Text1.Text[/italic]
    : : :
    : :
    : : One warning, you want to be careful in 'hard-coding' and assuming the path for where acrobat [or any windows program] is installed.
    : : What happens if the user did not install acrobat in the default Program files folder? By checking the registry you will be sure of the install path.
    : :
    : :
    :
    : well the best way to do it would be to use the ShellExecute API to launch to pdf. that way, whichever default application is set to be a pdf reader will open it, but the OP didn't sound like he was ready to get into API yet. it made more sense just to show him how to concatenate strings.
    :


    Thanks but i got a bit of code linking to a database so the user can change the location if they need to
Sign In or Register to comment.