FileSystemObject (fso.copyfile) copying file in memory, or on the drive?

KyleB

Registered User.
Local time
Yesterday, 23:00
Joined
Sep 14, 2001
Messages
71
I'm attempting to set up a locked excel file to be used as a framework that has a command button with vba code attached that will save the edited file as a new file name. The code seems to work, insofar as it does time stamp and rename the file as I intend. The problem I'm encountering, is that it will only save what appears to be the base file out as the new name, but without any of the current edits showing on screen.

I suspect this is because the system call is indeed copying the file, but it's copying the unedited version already on the drive, not the temporary file loaded and edited on screen. However, I do not want to save the changes to the current master file, that's the whole point to having a locked version, I want the original to remain unchanged, and unchangeable(permanently anyway), but allow temporary edits that then save out to a time stamped secondary file.

Web searches are so far failing to answer the question I want to know, does the fso.copyfile command allow you to save the current state of the open excel file, or only the last saved version already on the drive?
 
Use the SaveAs method of the Excel Application.
 
Use the SaveAs method of the Excel Application.


Thank you, but I've tried that, this is what I get->

run-time error '438':
Object doesn't support this property or method

Unfortunately that is my issue. Unless there's another implementation I'm unaware of in my searching.

Edit: hmm, unless you're referring to the Excel.Application command, and I misunderstood. But that begs the question, can I define my own filename to save the object as, and bypass user input for that dialog box? That's where I was heading with this function. I will do some looking at the command.
 
Last edited:
Sorry my mistake.

It is the SaveAs Method of the workbook object.

oBook.SaveAs strFilename
 
Excellent, that did exactly what I was looking for. I was just over-complicating the procedure with a function call that wasn't necessary.

*Note: In answer to my earlier question it appears that fso.command is simply for external file manipulation while inside of an excel file. For instance, combining or loading txt files to bring in via vba, or other external file manipulations. The command doesn't affect the instance currently loaded into memory, but unsaved as far as I'm able to determine.
 

Users who are viewing this thread

Back
Top Bottom