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 RetValRetVal = 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

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.

: : 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.

: : : 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