Automation - Long String to Excel

B

Bob Barnes

The string M in the code snippet below is a
long path to a File on a Server.

When the code tries to open the Workbook...
Set objXLWb = objXLApp.Workbooks.Open(M)
......''it says it can't find the File.

It there a "limitation" to automating to a Server File?
I have done plenty of automation to Local (C:) Files,
and can modify my design to populate a Local File &
then send it to a User.

Thoughts?? TIA - Bob

M = "\\T01A3F1\Abcdef\" _
& " AM DAILY REPORT DO NOT DELETE\" _
& "Daily Report\" _
& "Daily Report Input Sheets\" _
& "Productivity Input.xls"
'Open Excel Session
Set objXLApp = CreateObject("Excel.Application")
'open workbook, error routine will create it if doesn't exist
'select desired worksheet
Set objXLWb = objXLApp.Workbooks.Open(M)
 
R

Ron2006

It is relatively infrequently that I see a directory start with a
space.

It looks to me as if the > & " AM DAILY REPORT DO NOT DELETE\" _ part
of your path has a space between the " and the A

Could that be it?

Ron
 
B

Bob Barnes

Yes, my Client, a rather BIG company, uses spaces in Folder & File Names.
Putting [ ] didn't work.

IF removing the spaces in this long path will solve the problem. I should be
able to recommend that and I am hopeful the Client will agree. In the
interim, I modified the code to a C: path, and it's fine.

Is that a sure solution? Of course I can always test this particular path
and ask the Client for approval..

Your thoughts please.

Thank you - Bob
 
R

Ron2006

The LEADING space was just very unusual, not necessarily a problem. I
was thinking that it was a typo type problem.

If it can't find the file, that typically means some type of typo
problem and an incorrect number of spaces somewhere is not easy to see.

I am out of ideas. I will have to think on the problem some more.

Ron
 
B

Bob Barnes

Ron,

The string is correct.

I successfully use code like this (w/ a space)...modified to not
Identify Folder names, but the space works..
Open "\\T01A3F1\ABCDE\ABC 2000\Main Database\pas123.mdb" For Input As #Filenum

Thank you - Bob
 
R

Ron2006

Bob,

We are both saying some things and I am not sure I am getting my
question to you stated clearly.

If you take your statement for the M string and make it more
continuious it comes out as:

M = "\\T01A3F1\Abcdef\ AM DAILY REPORT DO NOT DELETE\" _
& "Daily Report\" _
& "Daily Report Input Sheets\" _
& "Productivity Input.xls"


And my question is not challenging the fact that there are spaces in
the middle of the directory names
BUT that there is a space between the M = "\\T01A3F1\Abcdef\ part

and the AM DAILY REPORT DO NOT DELETE\ part of the directory. See the
first line of my M= above.

That is the part that I find unusual. the space between the \ and the
first letter of the directory name. Your example in your last reply DID
NOT have any spaces in that position and that is what I am questioning.

I am asking it again just to try to make sure that you are
understanding what I am asking.


Ron
 

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

Top