View Single Post
  #14   Report Post  
Posted to microsoft.public.excel.programming
Grace[_4_] Grace[_4_] is offline
external usenet poster
 
Posts: 106
Default Filename problem

The message box does return the right string. Actually, I am now having a
problem with the earlier, similar, save file as an EXCEL file command

fname = StrMGR_SHORT_NAME & Sheets("INPUTS").Range("B45").Value &
Sheets("INPUTS").Range("E11").Value & ".xls"

It says object variable or with block variable not set.

Can anyone explain this?

Thanks,
Grace
"Rob van Gelder" wrote in message
...
I don't know what the problem is. You'll need some debugging info to

figure
out what's going on.

So your code will read something like:

myFilename = MGR_SHORT_NAME & Sheets("Inputs").Range("E11").Value &

"SUMPRF"
& ".L00"
MsgBox myFilename

(or even better than MsgBox, Debug.Print)

Then you'll see if myFilename is getting set correctly.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Grace" wrote in message
...
Per Norman, I have dimensioned it as a string and renamed it
strMGR_SHORT_NAME. The subroutine (where the variable IS picked up in
another such filename) calls another subroutine and it is not

re-dimensioned
there and does not seem to be picked up there. Would that help?

I tried the & instead of +, but it doesn't help. Does the & also apply

to
the + "*.xls", or just the strings in the name?

Any other ideas?

Dean

"Rob van Gelder" wrote in

message
...
Could you tell us how you declare MGR_SHORT_NAME?

Also, use & instead of + when concatenating strings.

--
Rob van Gelder - http://www.vangelder.co.nz/excel


"Grace" wrote in message
...
Is there something wrong with the following code?

myFilename = MGR_SHORT_NAME + Sheets("Inputs").Range("E11").Value +
"SUMPRF"
+ ".L00"

It keeps bombing out when it goes to find this file, because the

actual
file, of course, was named so that it has the MGR_short_name in the

front
part of its name, but the macro doesn't seem to recognize it, i.e.,

when
it
responds that it cannot find the file, the name it says it is

looking
for,
does not have this first part.

Thanks,
Grace