Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically Saving A Workbook


I would like to be able to save a workbook using a macro, that will save
the file in a particular loaction e.g. C:\My Documents\Spreadsheet
Files\Example Spreadsheet.xls and have the directory created for those
users for whom it does not exist.

I would also like the file to be named according to the contents of
cell c2 on a sheet named "list"

Any help would be much appreciatted.


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=558861

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Automatically Saving A Workbook

answers? no. guidance to where you could find help on using the file
system? yes:

the visual basic help file is pretty useless to beginers, but if you
are pointed in the right direction it can be very valuable.

here is a technical article from msdn about the FileSystemObject. that
should be a good starting place. Most of the methods are linked in the
msdn, otherwise type it into visual basic and hit F1.

any more questions feel free to post them.

MW

"if you give a man a fish, you feed him for a day. if you teach a man
to fish, you feed him for a lifetime."


Papa Waigo wrote:
I would like to be able to save a workbook using a macro, that will save
the file in a particular loaction e.g. C:\My Documents\Spreadsheet
Files\Example Spreadsheet.xls and have the directory created for those
users for whom it does not exist.

I would also like the file to be named according to the contents of
cell c2 on a sheet named "list"

Any help would be much appreciatted.


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=558861


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Automatically Saving A Workbook


Sub SaveFile()
Dim s as String, sName as String
s = "C:\My Documents\Spreadsheet Files\"
On Error Resume Next
Mkdir "C:\My Documents"
MkDir "C:\My Documents\Spreadsheet Files"
On Error goto 0
sName = ActiveWorkbook _
.Worksheets("List").Range("c2").Text & ".xls"
if dir(s & sName) < "" then
kill s & sName
End if
ActiveWorkbook.SaveAs s & sName
end sub

--
Regards,
Tom Ogilvy



"Papa Waigo" wrote:


I would like to be able to save a workbook using a macro, that will save
the file in a particular loaction e.g. C:\My Documents\Spreadsheet
Files\Example Spreadsheet.xls and have the directory created for those
users for whom it does not exist.

I would also like the file to be named according to the contents of
cell c2 on a sheet named "list"

Any help would be much appreciatted.


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=558861


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically Saving A Workbook


Thank you for your help here

This code gives me a "subscript out of range" error

any ideas?


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=558861

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Automatically Saving A Workbook

That would be true if the activeworkbook doesn't have a worksheet with a name
of LIST.

--
Regards,
Tom Ogilvy


"Papa Waigo" wrote:


Thank you for your help here

This code gives me a "subscript out of range" error

any ideas?


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=558861




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Automatically Saving A Workbook


Many thanks again, I can see what I've done wrong, this works
perfectly.

How would i change this so that if the filename already exists a msgbox
appears stating that is the case, and the macro would stop running?


--
Papa Waigo
------------------------------------------------------------------------
Papa Waigo's Profile: http://www.excelforum.com/member.php...o&userid=36074
View this thread: http://www.excelforum.com/showthread...hreadid=558861

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
Color Changes When Saving 2007 Workbook as 97 - 2003 Workbook Don Excel Discussion (Misc queries) 0 April 20th 08 04:51 AM
Automatically saving changes Jens Palacios Neffke[_2_] Excel Discussion (Misc queries) 3 April 17th 07 08:00 AM
Automatically saving changes Jens Palacios Neffke Excel Discussion (Misc queries) 1 April 17th 07 07:52 AM
saving workbook to destination file automatically mikespeck Excel Worksheet Functions 5 August 22nd 06 10:13 PM
Saving a Workbook: Forcing User to Rename before Saving Rollin_Again[_6_] Excel Programming 5 April 16th 04 02:54 PM


All times are GMT +1. The time now is 02:19 AM.

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

About Us

"It's about Microsoft Excel"