Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 11th, 2003, 11:09 AM
Daniel77573 Daniel77573 is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Posts: 1 Daniel77573 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Post SHELL function problem

Working in EXCEL i have this two similar Sub's:
«Convert» & «EBook» the first one works, but «EBook» doesn't.
any help? Thx!
-------------------------------------------------------------
Sub Convert()
On Error Resume Next
ChDir "M:\Utilities"
Program = "Convert.exe"
TaskID = Shell(Program, 1)
On Error GoTo 0
If Err <> 0 Then
MsgBox "Cannot start" & Program, vbCritical, "Error"
End If
End Sub
-----------------------------------------
Sub EBook()
On Error Resume Next
ChDir "G:\My Documents\"
Program = "New.pdf"
TaskID = Shell(Program,1)
On Error GoTo 0
If Err <> 0 Then
MsgBox "Cannot start" & Program, vbCritical, "Error"
End If
End Sub
------------------------------------------

Reply With Quote
  #2  
Old December 12th, 2003, 12:39 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
Oh!"New.pdf" is a document,just not a executable file.So u shouldn't shell it!!..

Reply With Quote
  #3  
Old December 12th, 2003, 03:59 AM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 96 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 44 m 59 sec
Reputation Power: 9
My understanding is that Shell (or something further down the chain) will make use of file associations, thus Acrobat Reader should be started in this case.

Daniel: Silly questions, perhaps - is Acrobat Reader installed on the target PC? Does "g:\My Documents\new.pdf" exist?

What happens if you double-click on new.pdf in Windows Explorer?

Reply With Quote
  #4  
Old December 16th, 2003, 04:23 AM
anth anth is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2003
Location: LONDON
Posts: 14 anth User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Smile

Use ShellExecuteEX function that will run on all windows platform It makes use of the association.

good luck

anth

Reply With Quote
  #5  
Old December 16th, 2003, 06:43 PM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
No!NicMic!Shell function couldn't use of file associations!Oly shellexecute and shellexecuteex function can do it!
And everyone who is interested look it:
Function introduce:
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

U can visit www.allapi.net for download API-Guide which is a great api search tools!
Sample:
Private 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
Const SW_SHOWNORMAL = 1
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
'Send an E-Mail to the KPD-Team
ShellExecute Me.hwnd, vbNullString, "mailto:KPDTeam@Allapi.net", vbNullString, "C:\", SW_SHOWNORMAL
End Sub

Reply With Quote
  #6  
Old December 17th, 2003, 03:42 AM
NicMic's Avatar
NicMic NicMic is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Cheltenham, England.
Posts: 96 NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level)NicMic User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 1 Day 44 m 59 sec
Reputation Power: 9
I stand corrected! Thanks for the update.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > SHELL function problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT