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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with path containing spaces

Status
Not open for further replies.

Shawn12

Programmer
Sep 27, 2006
50
US
I am trying to open a workbook with a command button however the path to the file is giving me a fit. The path for the file location contains spaces and I am going blind trying to figure out how to rectify the path. Heres the line. I am sure someone here will see this problem quick! Thanks.

Heres the actual path: N:\OPS\COMMON\OpsResearch\Contact Center\DI CCL Reporting dB\Apps by Agent.xls

Heres the mess I made out of it:
stAppName = "Excel.exe N:\OPS\COMMON\OpsResearch\Contact" & Chr(34) & "Center\DI" & Chr(34) & "CCL" & Chr(34) & "Reporting" & Chr(34) & "dB\Apps" & Chr(34) & "by" & Chr(34) & "Agent.xls
 
OOPS! That is supposed to look like this:

Heres the mess I made out of it:
stAppName = "Excel.exe N:\OPS\COMMON\OpsResearch\Contact" & Chr(32) & "Center\DI" & Chr(32) & "CCL" & Chr(32) & "Reporting" & Chr(32) & "dB\Apps" & Chr(32) & "by" & Chr(32) & "Agent.xls
 


Hi,

Why won't this work?
Code:
sFile = "N:\OPS\COMMON\OpsResearch\Contact Center\DI CCL Reporting dB\Apps by Agent.xls"
'...
workbooks.open sFile


Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Or this,

Code:
ChDir "N:\OPS"
    Workbooks.Open Filename:="N:\OPS\COMMON\OpsResearch\Contact Center\DI CCL Reporting dB\Apps by Agent.xls"

-Phish
"Why do you need to think? Can't we just sit and go budumbudumbudum with our lips for a bit?" - Mostly Harmless
fsm.png
 
Like this?

Private Sub Command2_Click()
On Error GoTo Err_Command2_Click

Dim stAppName As String
Dim sFile as String

stAppName = "Excel.exe"
Call Shell(stAppName, 1)

sFile = "N:\OPS\COMMON\OpsResearch\Contact Center\DI CCL Reporting dB\Apps by Agent.xls"

Workbooks.Open sFile



Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click

End Sub

This just seems to error.
 



What application are you running this code in?

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 

Also, what's the ERROR message?

Manually open the workbook.

Activate the WEB toolbar

COPY the Path & Filename and COMPARE to the string that you posted.

Chances are they are NOT the same.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 


Phish,

directory commands do not affect the Open method as posted.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
I am using a Command Button on an Access Form to try and open this file. Try being the key word..Excel opens fine then it tells me "Object Required".
 
And what about this ?
stAppName = "Excel.exe ""N:\OPS\COMMON\OpsResearch\Contact Center\DI CCL Reporting dB\Apps by Agent.xls"""

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thx PHV...see I always try to do stuff the hard way. I hate quotations..
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top