shell command not working with the spaces in file name

hfs

Registered User.
Local time
Today, 08:27
Joined
Aug 7, 2013
Messages
47
Hey Guys,

I am in trouble with the shell ocmmand,i have a text box "ExcelPath Location" in which there is a path of excel file i am using below code to open the excel file but it gives an error:

Code:
Private Sub Command11_Click()
 
Dim str As String
str = ExcelPathLocation.Value
 
strPath = Dir(str)
 
Shell "excel.exe" & """" & strPath & """", vbNormalFocus
 
 
End Sub
the value of text box is

O:\QA Files\QC Reporting\Pending Review\B329129)419479_BoxPort_RAMANDEEP BRAR_(10192013.xlsm

it gives run time error : 53
file not found


REally need immediate help,
Thanks in advance
 

Attachments

  • Capture.JPG
    Capture.JPG
    24.5 KB · Views: 152
Try this.
Code:
Private Sub Command11_Click()
    Dim str As String
    str = ExcelPathLocation
     
    strPath = Dir(str)
    If strPath <> vbNullString Then  Application.FollowHyperlink str
End Sub
 
Thanks Paul,

You always reply my stupid programming questions !! Thanks Alot That worked ,it feels so good when a problem is solved :):)
 

Users who are viewing this thread

Back
Top Bottom