Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
filesystemobject | Excel Programming | |||
Help using FileSystemObject CopyFile | Excel Programming | |||
FileSystemObject | Excel Programming | |||
CopyFile usage | Excel Programming | |||
FileSystemObject CopyFile with UserID/Password | Excel Programming |