Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2006

Tip: Looking for answers? Try searching our database.

Save workbook via Command Button????

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris Watson - 23 Mar 2006 07:56 GMT
I have a workbook with a command button and need to save the workbook
with a date as the file name. The date is in cell "A5" and the file I
need to save it to is "Midtown Farm". Can anyone help please???

Signature

Chris Watson

chillihawk - 23 Mar 2006 09:52 GMT
Do you mean you have a file you want to save called 'Midtown Farm' and
you want to append the date in cell 'A5' to the end of the filename?
If so and the onClick event of the command button triggers the save
operation then you could do something like this:

Private Sub CommandButton1_Click()

Dim sDate as string

sDate = Format(Activesheet.Range("A5").Value, "yyyymmdd")

Thisworkbook.SaveAs "Midtown Farm_" & sDate

End Sub
Chris Watson - 23 Mar 2006 10:44 GMT
This works fine but What I want it to do is save the workbook in
folder call Midtown Farm in My documents, is this possible???
chillihawk - 23 Mar 2006 11:11 GMT
Sorry I misunderstood.  In which case:

Thisworkbook.SaveAs "C:\My Documents\Midtown Farm\" & sDate

A note of caution however: 'My Documents' is not always where you think
it is.  If you are on a standalone desktop then it is probably where
I've indicated, if you are on a corporate network then it may well be
on a network drive.  To resolve the location open Explorer and
right-click->Properties on 'My Documents' the 'Target' tab will show
you the full path to the folder and then you just stick that in the
SaveAs command as I've shown.

HTH
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.