Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Shell function

Posted on 2005-04-12
9
Medium Priority
?
248 Views
Last Modified: 2010-05-02
Hi

 I have problem for opening files in the later versions of Acrobat. How can I modify this line to open the file in any versions of acrobat?

dblfile = Shell("C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe ""C:\Program Files\CheckSystem\External Data\Logical Information\Logical Time\Myfile.pdf", vbMaximizedFocus)

Thanks for your suggestion.
0
Comment
Question by:bincem
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 53

Expert Comment

by:Dhaest
ID: 13769820
0
 
LVL 33

Accepted Solution

by:
sajuks earned 400 total points
ID: 13769821
Use the shellexecute api and let windows decide what would be the program...
//credit to  ryancys ( not sure of the actual coder, i 'd this code some time back with me )

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

Public Function StartDoc(ByVal FileName As String, Optional CommandLine As String = "") As Long
    StartDoc = ShellExecute(0&, "Open", FileName, CommandLine, vbNullString, 1)
End Function

Call like:

StartDoc "C:\test.pdf"

0
 
LVL 54

Expert Comment

by:Ryan Chong
ID: 13770297
Yes, use ShellExecute API

btw, sajuks, i think the only lines originally from me is  Public Function StartDoc ...  not big improvement just make it easier to use (yes many others may have same codes as mine) , anyway just my $0.02 ;-) cheers
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:bincem
ID: 13771288
Hi sajuks.

That is the perfect solution.

Thank you
Bince
0
 
LVL 33

Expert Comment

by:sajuks
ID: 13771300
Thanks for the points and grade..
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13771431
So I better post only the function you need and no longer to the complete explanation of how and what shellexecute is then for getting the points !!!
0
 
LVL 33

Expert Comment

by:sajuks
ID: 13771496
hey Dhaest, if u see the psots we've both posted at the same time...i dont mind u asking for a split from CS for it.

:-)
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 13771563
To "sajuks": Now is just see it that we both posted at the same time, so just ignore my previous remark.
Thx for the info.
0
 

Author Comment

by:bincem
ID: 13773674
Hi Dhaest,

Infact both post came in the same time and I was in a hurry to resolve that issue.
sajuks posted the code along with his answer. I just tried 'sajuks' code and it did work at first time itself. Immediatly I accepted the answer. Now only I realized both of you posted the same solution. Thanks a lot for your effort.

Bince
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Suggested Courses
Course of the Month20 days, 21 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question