View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Pat Beck Pat Beck is offline
external usenet poster
 
Posts: 7
Default Comments on this code to FTP save, please?

Excel 2002
WinXP Home
Win2000

Hi. I see from the archives this has been asked many times, but I ended up
with a different solution than those I read and would like feedback. (Maybe
this has been suggested and I didn't see it.) Like others, I need to edit a
workbook and then save it to an FTP site. I want code to do that, hopefully
simple code.

I found (without code) I could initially save it to an FTP site, and "save
as" code would successfully resave it to the FTP site. But upon reopening my
file from my hard drive I found the "save as" code erred, as though it could
not negotiate contact with the FTP site.

But I also found that if I first opened a file from the site (got a session
going) the code worked beautifully. So, as a rigged solution, I simply added
code that would do that very thing. And it works.

It seems too simple, so I'm asking for comments. Would you please look at
this short code and tell me your thoughts as to potential problems/success.
Thanks.

Notes:
- I left out error handlers & screen update.
- ftp://www.myftp.com is an alias for a real FTP site.
- Empty.xls is a blank workbook.
- Budget.xls is the subject workbook being edited.
- I also left out code that saves file to the hard drive (in addition to
saving to FTP).

Here's the code:

Sub SaveToFTP()

'Open a file from FTP site.
Workbooks.Open Filename:="ftp://www.myftp.com/files/Empty.xls"
'Dialog box asks for password and opens file.
'Close file.
ActiveWorkbook.Close

'Save budget file to FTP.
ActiveWorkbook.SaveAs Filename:= _
"ftp://www.myftp.com/files/Budget.xls", FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False

End Sub


Thanks again,
Pat Beck