Opening a file with a space in the name?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This line works...

Set working = Workbooks.Open("L:\theFolder\TheEmail.xls")

this one returns a 1004 error...

Set working = Workbooks.Open("L:\theFolder\TheEmail.xls")

getting "smart" I tried...

Set working = Workbooks.Open("""L:\theFolder\The Email.xls""")

The file in question WILL have a space in the name when we receive it. Is
there some trick to opening the file when there's a space in the name?

Maury
 
So you mean the file received may or may not have space?
If this is the case then try:-

On Error Resume Next
Set working = Workbooks.Open("L:\theFolder\TheEmail.xls")
If Err <> 0 Then
Err.Clear
Set working = Workbooks.Open("L:\theFolder\The Email.xls")
End If
On Error GoTo 0

Sharad
 
You must have misspelled the name (maybe it has two spaces).

This worked fine for me (demo'd from the immediate window)

set wkbk = Workbooks.Open("C:\Data\Data1\Data2\A B C D E F.xls")
? wkbk.Name
A B C D E F.xls
 
Hi Maury,

One thing you can try:

1) Go to Tools | Options, General tab, and make sure "Ignore other
applications" is unchecked.

If that doesn't work, close Excel and try this:

2) Go to Start | Run in Windows, type "excel /regserver", and click OK.


--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Perhaps it is not a space, just looks like one. If in Excel you use File +
Save AS, type MY followed by Alt + digits 2 5 5 on the numeric keypad followd
by some file.xls, the resulting filename looks like MY file.xls but the
character between the Y and the f is NOT a space.
 
AA2e72E said:
Perhaps it is not a space, just looks like one. If in Excel you use File +
Save AS, type MY followed by Alt + digits 2 5 5 on the numeric keypad followd
by some file.xls, the resulting filename looks like MY file.xls but the
character between the Y and the f is NOT a space.

I think this is the problem. I wiped out the filename and retyped it with
the space and it worked ok!

Maury
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top