getting the File System Object to run File Save As instead of just File Save

  • Thread starter Thread starter Paul
  • Start date Start date
P

Paul

I'm using the following code to save a file from a template folder into
another folder:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile strTemplateFile, strProjectFile
SetAttr strProjectFile, vbNormal
Set fso = Nothing

In its present form, this code will overwrite the target file if it already
exists. If I set a third parameter to False, I can prevent the CopyFile
method from overwriting an existing file, but then it just displays a
message saying the file already exists and doesn't give the user a chance to
choose whether to overwrite the file or save it with another filename.

Is there a way I can modify the line

fso.CopyFile strTemplateFile, strProjectFile

so that it will open a Save As dialog so the user can choose whether to
overwrite the file or save it with a different name? It would also be great
if the Save As dialog defaulted to the folder path where the existing file
is located.

Thanks in advance,

Paul
 
Thanks for the reply, and the link to that MSDN article, Tom.

Shortly after I began reading it, however, I realized I wasn't understanding
how I could use it to accomplish what I'm trying to do. So I printed out
the entire article, which runs no less than 15 full pages in WordPad, and
went after it with my yellow highlighter, hoping to figure it out. By time
I got to page 8, my mind had numbed over and I was hopelessly lost. So I
tried copying the various code samples including the class module at the end
of the article, which itself is five pages long, into my VB Editor, but I
couldn't even get it to compile, much less run.

In looking at that Web page again, I have to believe it's directed at
advanced developers, which I am not. Is there any chance I could get you to
help me with this by copying and pasting the portion of code on that Web
page that would open a SaveAs dialog?

Thanks

Paul
 
Back
Top