Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17974
Number of posts: 55343

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
opening pdf`s Posted by darthmill on 2 Feb 2005 at 1:46 PM
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 Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe d:\Till Manuals\120.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
Report
Re: opening pdf`s Posted by the walrus on 2 Feb 2005 at 11:26 PM
you'll want to do something like this

Private Sub Command2_Click() 
Dim RetVal 
RetVal = Shell("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & Text1.Text, vbMaximizedFocus) 
End Sub 


to open the location that's in Text1.Text
Report
Re: opening pdf`s Posted by darthmill on 3 Feb 2005 at 11:15 AM
: you'll want to do something like this
:
:
Private Sub Command2_Click() 
: Dim RetVal 
: RetVal = Shell("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & Text1.Text, vbMaximizedFocus) 
: End Sub 

:
: to open the location that's in Text1.Text
:
Thanks it worked
Report
Re: opening pdf`s Posted by dokken2 on 7 Feb 2005 at 9:19 AM
: you'll want to do something like this
:
:
Private Sub Command2_Click() 
: Dim RetVal 
: RetVal = Shell("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & Text1.Text, vbMaximizedFocus) 
: End Sub 

:
: to open the location that's in Text1.Text
:

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.

Report
Re: opening pdf`s Posted by the walrus on 7 Feb 2005 at 5:32 PM
: : you'll want to do something like this
: :
: :
Private Sub Command2_Click() 
: : Dim RetVal 
: : RetVal = Shell("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & Text1.Text, vbMaximizedFocus) 
: : End Sub 

: :
: : to open the location that's in Text1.Text
: :
:
: 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.
Report
Re: opening pdf`s Posted by darthmill on 8 Feb 2005 at 11:02 AM
: : : you'll want to do something like this
: : :
: : :
Private Sub Command2_Click() 
: : : Dim RetVal 
: : : RetVal = Shell("C:\Program Files\Adobe\Acrobat 7.0\Reader\AcroRd32.exe " & Text1.Text, vbMaximizedFocus) 
: : : End Sub 

: : :
: : : to open the location that's in Text1.Text
: : :
: :
: : 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



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.