Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default FileSystemObject.copyfile


I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and they point
to a file and directory that exists.... Is there something else I should be
checking, or is it likely to be something about the paths and filename that
I'm not seeing? I have network access to all of these areas and use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 244
Default FileSystemObject.copyfile

It looks OK, so it MIGHT be worth storing the strings in variables and
using those rather than getting the CopyFile to concatenate.

KR wrote:
I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and they point
to a file and directory that exists.... Is there something else I should be
checking, or is it likely to be something about the paths and filename that
I'm not seeing? I have network access to all of these areas and use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default FileSystemObject.copyfile

Maybe try:

Dim FSO as FileSystemObject
'then do:
FSO.CopyFile

'AND you need a destination filename

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls " & DestFileName '(note the trailing space after .xls)

'(But I don't know about that LanID part, I removed it)


" wrote:

It looks OK, so it MIGHT be worth storing the strings in variables and
using those rather than getting the CopyFile to concatenate.

KR wrote:
I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and they point
to a file and directory that exists.... Is there something else I should be
checking, or is it likely to be something about the paths and filename that
I'm not seeing? I have network access to all of these areas and use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default FileSystemObject.copyfile

Sorry, it's not a space after the ".xls" it's a comma

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls", DestFileName

"Charlie" wrote:

Maybe try:

Dim FSO as FileSystemObject
'then do:
FSO.CopyFile

'AND you need a destination filename

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls " & DestFileName '(note the trailing space after .xls)

'(But I don't know about that LanID part, I removed it)


" wrote:

It looks OK, so it MIGHT be worth storing the strings in variables and
using those rather than getting the CopyFile to concatenate.

KR wrote:
I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and they point
to a file and directory that exists.... Is there something else I should be
checking, or is it likely to be something about the paths and filename that
I'm not seeing? I have network access to all of these areas and use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default FileSystemObject.copyfile

and

Dim FSO as New FileSystemObject

for some reason need "New"

"Charlie" wrote:

Sorry, it's not a space after the ".xls" it's a comma

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls", DestFileName

"Charlie" wrote:

Maybe try:

Dim FSO as FileSystemObject
'then do:
FSO.CopyFile

'AND you need a destination filename

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls " & DestFileName '(note the trailing space after .xls)

'(But I don't know about that LanID part, I removed it)


" wrote:

It looks OK, so it MIGHT be worth storing the strings in variables and
using those rather than getting the CopyFile to concatenate.

KR wrote:
I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and they point
to a file and directory that exists.... Is there something else I should be
checking, or is it likely to be something about the paths and filename that
I'm not seeing? I have network access to all of these areas and use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith




  #6   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default FileSystemObject.copyfile

I incorporated both suggestion, and my code snippet is now:

CopySource = RnRPath & WorkingFiles & RnRTemplate
CopyDestination = RnRPath & LanID & ".xls"
Dim FSO As New filesystemobject
FSO.CopyFile CopySource, CopyDestination

Both strings are concatenating properly, but....
I think this has identified an underlying problem that isn't mentioned in
the help file; The concatenation still works, but I'm getting a compile
error on the Dim FSO as New FileSystemObject line- and as you can see above,
it doesn't autorecognize the word and add the caps (FileSystemObject vs
filesystemobject).

Does the use of a FileSystemObject require a reference setting? I don't have
any missing references listed, but I'm not sure why else I wouldn't be able
to reference a filesystem object. Using XL2003 on Win2000

Thanks,
Keith

"Charlie" wrote in message
...
and

Dim FSO as New FileSystemObject

for some reason need "New"

"Charlie" wrote:

Sorry, it's not a space after the ".xls" it's a comma

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls", DestFileName

"Charlie" wrote:

Maybe try:

Dim FSO as FileSystemObject
'then do:
FSO.CopyFile

'AND you need a destination filename

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls " & DestFileName '(note the trailing space after

..xls)

'(But I don't know about that LanID part, I removed it)


" wrote:

It looks OK, so it MIGHT be worth storing the strings in variables

and
using those rather than getting the CopyFile to concatenate.

KR wrote:
I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and

they point
to a file and directory that exists.... Is there something else I

should be
checking, or is it likely to be something about the paths and

filename that
I'm not seeing? I have network access to all of these areas and

use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default FileSystemObject.copyfile

You need the Microsoft Scripting Runtime library. From your VBE window do:

Tools--References

(it might take a moment to open). Then scroll down to find the library and
click the checkbox (don't just highlight the line.) Click Ok.

"KR" wrote:

I incorporated both suggestion, and my code snippet is now:

CopySource = RnRPath & WorkingFiles & RnRTemplate
CopyDestination = RnRPath & LanID & ".xls"
Dim FSO As New filesystemobject
FSO.CopyFile CopySource, CopyDestination

Both strings are concatenating properly, but....
I think this has identified an underlying problem that isn't mentioned in
the help file; The concatenation still works, but I'm getting a compile
error on the Dim FSO as New FileSystemObject line- and as you can see above,
it doesn't autorecognize the word and add the caps (FileSystemObject vs
filesystemobject).

Does the use of a FileSystemObject require a reference setting? I don't have
any missing references listed, but I'm not sure why else I wouldn't be able
to reference a filesystem object. Using XL2003 on Win2000

Thanks,
Keith

"Charlie" wrote in message
...
and

Dim FSO as New FileSystemObject

for some reason need "New"

"Charlie" wrote:

Sorry, it's not a space after the ".xls" it's a comma

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls", DestFileName

"Charlie" wrote:

Maybe try:

Dim FSO as FileSystemObject
'then do:
FSO.CopyFile

'AND you need a destination filename

FSO.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & ".xls " & DestFileName '(note the trailing space after

..xls)

'(But I don't know about that LanID part, I removed it)


" wrote:

It looks OK, so it MIGHT be worth storing the strings in variables

and
using those rather than getting the CopyFile to concatenate.

KR wrote:
I'm using the following:

FileSystemObject.CopyFile _
RnRPath & WorkingFiles & RnRTemplate, _
RnRPath & LanID & ".xls"

and getting a runtime 424 object required error.

RnRPath is a network path, e.g. "\\server\folder\"
WorkingFiles is just a subfolder, e.g. "subfolder\"
RnRTemplate is a filename, e.g. "MyFile.xls"
And LanID is the user's login ID string, e.g. "myname"

I've checked the string assignments for the above variables, and

they point
to a file and directory that exists.... Is there something else I

should be
checking, or is it likely to be something about the paths and

filename that
I'm not seeing? I have network access to all of these areas and

use these
files 'manually', just can't seem to get it working in code.

Thanks!
Keith





  #8   Report Post  
Posted to microsoft.public.excel.programming
KR KR is offline
external usenet poster
 
Posts: 121
Default FileSystemObject.copyfile

Before I got your response, I kept trying, and finally found a similar
solution from an old post; they used:
Set FSO = CreateObject("Scripting.FileSystemObject")
Which seems to work even without the reference. I'll check the reference
just for future use, and it looks like I'm good to go!
Thanks again for all the help!!
Keith

"Charlie" wrote in message
...
You need the Microsoft Scripting Runtime library. From your VBE window

do:

Tools--References

(it might take a moment to open). Then scroll down to find the library

and
click the checkbox (don't just highlight the line.) Click Ok.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
filesystemobject Alvin Hansen[_2_] Excel Programming 3 January 27th 05 06:17 PM
Help using FileSystemObject CopyFile Tod Excel Programming 1 May 12th 04 10:18 PM
FileSystemObject lol[_2_] Excel Programming 2 April 6th 04 09:56 PM
CopyFile usage Garry[_5_] Excel Programming 1 January 19th 04 08:56 PM
FileSystemObject CopyFile with UserID/Password Tod[_3_] Excel Programming 0 January 7th 04 06:03 PM


All times are GMT +1. The time now is 11:17 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"