Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell or Shell execute? in VB6 2

Status
Not open for further replies.

Imbriani

Programmer
Jan 9, 2004
195
US
Hi All,

I am trying to open a pdf document in Adobe Acrobat from inside a VB program. If the hyperlink shows in a text box(this is a local program and the files are found on a local drive, can I put a button below that opens that hyperlink in Acrobat? Am I on the right track with something like:
Shellexecute.d:\articles\article.pdf???

Thanks in advance, oh and would someone please tell me how to give stars???

Kathy
 
Do the declaration at module level:
[tt]
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
[/tt]

Then in your command_click:
[tt]
ShellExecute &0, "Open", "d:\articles\article.pdf", vbNullString, "", SW_SHOWNORMAL
[/tt]
Read faq222-2244 for forum usage guidelines, para 15 for details of acknowledgement

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Can I get the name of the desired file from a text box right above the command button? Maybe something like:

ShellExecute &0, "Open", "txtarticle.Text", vbNullString, "", SW_SHOWNORMAL ??
 
Just remove the quotes from the control name.

Code:
ShellExecute &0, "Open", txtarticle.Text, vbNullString, "", SW_SHOWNORMAL

zemp
 
You can as long as what is in the text box contains the full path and filename with extension.
 
Zemp,

Thanks you so much. That was simple and straightforward, just what I need.

While I'm asking questions, how do you format a datagrid box NOT to show the gray area around the dataset after the program is run? I can't seem to accomplish that in the properties section. This is in the code, isn't it? Maybe resize?

And here's a star for your simplicity!
 
Hi All Again,

When I tried to put the Public Declare in my class module, I got an error that declare statements are not allowed as member of Public statements. That and constants and other members. Any suggestions?

Here's the code I put in:

Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

I put this in the General Declarations.

 
If you're using it within a Class module, declare it as Private.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top