Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default PLEASE HELP!!! PLEASE!!!

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default PLEASE HELP!!! PLEASE!!!

On Sep 3, 7:56*am, Damil4real wrote:
How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!


Can someone help me please?
  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default PLEASE HELP!!! PLEASE!!!

On Sep 3, 8:05*am, Damil4real wrote:
On Sep 3, 7:56*am, Damil4real wrote:





How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.


Example:


Save workbook as "Monthly Expenses 1-Sept-08"


The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!


Can you please help me ASAP????


THANKS A BUNCH!


Can someone help me please?- Hide quoted text -

- Show quoted text -


Please help!!!
  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default PLEASE HELP!!! PLEASE!!!

Instead of re-posting every 9 minutes, why don't you spend your time
searching the Excel groups on Google - I'm sure you will find
something in the archives. I'm going out now, so I don't have time to
test out a solution.

Pete

On Sep 3, 2:14*pm, Damil4real wrote:
On Sep 3, 8:05*am, Damil4real wrote:





On Sep 3, 7:56*am, Damil4real wrote:


How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.


Example:


Save workbook as "Monthly Expenses 1-Sept-08"


The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!


Can you please help me ASAP????


THANKS A BUNCH!


Can someone help me please?- Hide quoted text -


- Show quoted text -


Please help!!!- Hide quoted text -

- Show quoted text -


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default PLEASE HELP!!! PLEASE!!!

On Sep 3, 8:20*am, Pete_UK wrote:
Instead of re-posting every 9 minutes, why don't you spend your time
searching the Excel groups on Google - I'm sure you will find
something in the archives. I'm going out now, so I don't have time to
test out a solution.

Pete

On Sep 3, 2:14*pm, Damil4real wrote:



On Sep 3, 8:05*am, Damil4real wrote:


On Sep 3, 7:56*am, Damil4real wrote:


How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.


Example:


Save workbook as "Monthly Expenses 1-Sept-08"


The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!


Can you please help me ASAP????


THANKS A BUNCH!


Can someone help me please?- Hide quoted text -


- Show quoted text -


Please help!!!- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -


I've searched the forum, but I didn't see any post relating to my
question. I'll appreciate any assistance. Sorry for the incovenience.

Thanks!


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 30
Default PLEASE HELP!!! PLEASE!!!

This should save the workbook to your path with the name that you want:

NewFile = "C:\YOUR PATH HERE\" & "Monthly Expenses " & Range(A1:A1) & ".xls"
WorkBook.SaveAs NewFile
WorkBook.Close False

Range(A1:A1) should be changed to the place where your date is. You may also
have to change the Cell value to a string by using DateToStr or something
similar.

--
Rui


"Damil4real" wrote in message
...
How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!



  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default PLEASE HELP!!! PLEASE!!!

Relax, young grasshopper - the ox is slow, but the earth is patient. It
takes time to:
read and comprehend a request, code and test a possible solution, and then
get it all back here for you to use.

I believe the code below will do what you want. It 'intercepts' the normal
workbook save process to do all that you want. You will need to change one
Const value that's set up in it, the path you want it saved into, once you've
copied it into your workbook.

This code works with the Workbook_BeforeSave event, and so it MUST go into a
particular area in the workbook. To get to that area:
Open your workbook.
RIGHT-click on the little Excel icon that is immediately to the left of the
word File in the Excel menu bar. Choose [View Code] from the popup list that
should appear.

Copy the code below and paste it into the code module that was presented to
you when you chose [View Code]. CHANGE the Const savePath to = "your real
path" (but actually put the path in between the quote marks and be sure there
is a path separator (\ for Wintel machines, : for Macs) at the end of that
path). There's an example of a revision to that line of code in the code
below.

Once you've done this properly, each time you try to save the workbook, it
will do as you have asked. The only way to save it somewhere else is going
to be to copy it from your special folder to where ever else you want a copy.

The code:

Private Sub Workbook_BeforeSave(ByVal _
SaveAsUI As Boolean, Cancel As Boolean)
'change this path to the path you want it to end up in
Const savePath = "C:\"

'for example you might change it to:
'Const savePath = _
"C:\Documents and Settings\All Users\Documents\ExcelHelpGiven\_TestFolder\"

Const basicName = "Monthly Expenses "
Static IAmBusy As Boolean
Dim currentDir As String
Dim newName As String

If IAmBusy Then
Exit Sub
End If
IAmBusy = True ' prevent reentry
Application.DisplayAlerts = False
currentDir = CurDir ' so we can restore it later
ChDir savePath ' get ready for the save in proper place
newName = basicName & Format(Now(), "dd-mmm-yyyy") & ".xls"
On Error GoTo CleanupAfterAbort ' just in case!
If Dir$(savePath & newName) < "" Then
'file exists, ask about overwriting
If MsgBox("File:" & vbCrLf & _
savePath & newName & vbCrLf & _
"Already Exists --- Overwrite it?", _
vbYesNo + vbCritical, "Overwrite Old File?") = vbYes Then
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
Else
MsgBox "File Save Cancelled by User"
Cancel = True
GoTo CleanupAfterAbort
End If
Else
'new file, just save it
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
End If
CleanupAfterAbort:
If Err < 0 Then
MsgBox "Error: " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & _
"Took place while trying to save the file!"
Err.Clear
End If
On Error GoTo 0 'reset error trapping
'restore the original default path
ChDir currentDir
Application.DisplayAlerts = True
'reset busy flag
IAmBusy = False
End Sub


"Damil4real" wrote:

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!

  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default PLEASE HELP!!! PLEASE!!!

Oh - it DOES NOT do ALL that you asked. It doesn't pick up that cell value
that you wanted it to as part of the filename. You'll need to tell us the
name of the worksheet that cell is on and what its address (A1, B9, XX44,
etc) is before we can help with that.


"Damil4real" wrote:

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!

  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default PLEASE HELP!!! PLEASE!!!

On Sep 3, 8:47*am, "ruic" wrote:
This should save the workbook to your path with the name that you want:

NewFile = "C:\YOUR PATH HERE\" & "Monthly Expenses " & Range(A1:A1) & "..xls"
WorkBook.SaveAs NewFile
WorkBook.Close False

Range(A1:A1) should be changed to the place where your date is. You may also
have to change the Cell value to a string by using DateToStr or something
similar.

--
Rui

"Damil4real" wrote in message

...



How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.


Example:


Save workbook as "Monthly Expenses 1-Sept-08"


The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!


Can you please help me ASAP????


THANKS A BUNCH!- Hide quoted text -


- Show quoted text -


Thanks for responding to my request! I'm totally new to VBA and macro,
so while what you posted might sound simple to a lot of people, I
might find it still kinda difficult to understand.

So how do I actually paste the code in the Microsoft Visual Basic?

I pasted your code directly into it, but it didn't recognize it all.
How am I supposed to post the code?

Is it like this?

Sub saveas()

NewFile = "C:\YOUR PATH HERE\" & "Monthly Expenses " & Range(A1:A1) &
".xls"
Workbook.saveas NewFile
Workbook.Close False

End Sub

Posting it like that is now working.

I appreciate any assistance.

Thanks!
  #10   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default PLEASE HELP!!! PLEASE!!!

Relax, young grasshopper - the ox is slow, but the earth is patient.

I like that :)

"JLatham" wrote:

Relax, young grasshopper - the ox is slow, but the earth is patient. It
takes time to:
read and comprehend a request, code and test a possible solution, and then
get it all back here for you to use.

I believe the code below will do what you want. It 'intercepts' the normal
workbook save process to do all that you want. You will need to change one
Const value that's set up in it, the path you want it saved into, once you've
copied it into your workbook.

This code works with the Workbook_BeforeSave event, and so it MUST go into a
particular area in the workbook. To get to that area:
Open your workbook.
RIGHT-click on the little Excel icon that is immediately to the left of the
word File in the Excel menu bar. Choose [View Code] from the popup list that
should appear.

Copy the code below and paste it into the code module that was presented to
you when you chose [View Code]. CHANGE the Const savePath to = "your real
path" (but actually put the path in between the quote marks and be sure there
is a path separator (\ for Wintel machines, : for Macs) at the end of that
path). There's an example of a revision to that line of code in the code
below.

Once you've done this properly, each time you try to save the workbook, it
will do as you have asked. The only way to save it somewhere else is going
to be to copy it from your special folder to where ever else you want a copy.

The code:

Private Sub Workbook_BeforeSave(ByVal _
SaveAsUI As Boolean, Cancel As Boolean)
'change this path to the path you want it to end up in
Const savePath = "C:\"

'for example you might change it to:
'Const savePath = _
"C:\Documents and Settings\All Users\Documents\ExcelHelpGiven\_TestFolder\"

Const basicName = "Monthly Expenses "
Static IAmBusy As Boolean
Dim currentDir As String
Dim newName As String

If IAmBusy Then
Exit Sub
End If
IAmBusy = True ' prevent reentry
Application.DisplayAlerts = False
currentDir = CurDir ' so we can restore it later
ChDir savePath ' get ready for the save in proper place
newName = basicName & Format(Now(), "dd-mmm-yyyy") & ".xls"
On Error GoTo CleanupAfterAbort ' just in case!
If Dir$(savePath & newName) < "" Then
'file exists, ask about overwriting
If MsgBox("File:" & vbCrLf & _
savePath & newName & vbCrLf & _
"Already Exists --- Overwrite it?", _
vbYesNo + vbCritical, "Overwrite Old File?") = vbYes Then
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
Else
MsgBox "File Save Cancelled by User"
Cancel = True
GoTo CleanupAfterAbort
End If
Else
'new file, just save it
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
End If
CleanupAfterAbort:
If Err < 0 Then
MsgBox "Error: " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & _
"Took place while trying to save the file!"
Err.Clear
End If
On Error GoTo 0 'reset error trapping
'restore the original default path
ChDir currentDir
Application.DisplayAlerts = True
'reset busy flag
IAmBusy = False
End Sub


"Damil4real" wrote:

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!



  #11   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 34
Default PLEASE HELP!!! PLEASE!!!

On Sep 3, 9:17*am, Mike H wrote:
Relax, young grasshopper - the ox is slow, but the earth is patient.

I like that :)



"JLatham" wrote:
Relax, young grasshopper - the ox is slow, but the earth is patient. *It
takes time to:
read and comprehend a request, code and test a possible solution, and then
get it all back here for you to use.


I believe the code below will do what you want. *It 'intercepts' the normal
workbook save process to do all that you want. *You will need to change one
Const value that's set up in it, the path you want it saved into, once you've
copied it into your workbook.


This code works with the Workbook_BeforeSave event, and so it MUST go into a
particular area in the workbook. *To get to that area:
Open your workbook.
RIGHT-click on the little Excel icon that is immediately to the left of the
word File in the Excel menu bar. *Choose [View Code] from the popup list that
should appear.


Copy the code below and paste it into the code module that was presented to
you when you chose [View Code]. *CHANGE the Const savePath to = "your real
path" (but actually put the path in between the quote marks and be sure there
is a path separator (\ for Wintel machines, : for Macs) at the end of that
path). *There's an example of a revision to that line of code in the code
below.


Once you've done this properly, each time you try to save the workbook, it
will do as you have asked. *The only way to save it somewhere else is going
to be to copy it from your special folder to where ever else you want a copy.


The code:


Private Sub Workbook_BeforeSave(ByVal _
*SaveAsUI As Boolean, Cancel As Boolean)
'change this path to the path you want it to end up in
Const savePath = "C:\"


'for example you might change it to:
'Const savePath = _
*"C:\Documents and Settings\All Users\Documents\ExcelHelpGiven\_TestFolder\"


Const basicName = "Monthly Expenses "
Static IAmBusy As Boolean
Dim currentDir As String
Dim newName As String


If IAmBusy Then
* Exit Sub
End If
IAmBusy = True ' prevent reentry
Application.DisplayAlerts = False
currentDir = CurDir ' so we can restore it later
ChDir savePath ' get ready for the save in proper place
newName = basicName & Format(Now(), "dd-mmm-yyyy") & ".xls"
On Error GoTo CleanupAfterAbort ' just in case!
If Dir$(savePath & newName) < "" Then
* 'file exists, ask about overwriting
* If MsgBox("File:" & vbCrLf & _
* *savePath & newName & vbCrLf & _
* *"Already Exists --- Overwrite it?", _
* *vbYesNo + vbCritical, "Overwrite Old File?") = vbYes Then
* * ThisWorkbook.SaveAs newName
* * MsgBox "File has been saved as: " & ThisWorkbook.Name
* Else
* * MsgBox "File Save Cancelled by User"
* * Cancel = True
* * GoTo CleanupAfterAbort
* End If
Else
* 'new file, just save it
* ThisWorkbook.SaveAs newName
* MsgBox "File has been saved as: " & ThisWorkbook.Name
End If
CleanupAfterAbort:
If Err < 0 Then
* MsgBox "Error: " & Err.Number & vbCrLf & _
* *Err.Description & vbCrLf & _
* *"Took place while trying to save the file!"
* Err.Clear
End If
On Error GoTo 0 'reset error trapping
'restore the original default path
ChDir currentDir
Application.DisplayAlerts = True
'reset busy flag
IAmBusy = False
End Sub


"Damil4real" wrote:


How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.


Example:


Save workbook as "Monthly Expenses 1-Sept-08"


The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!


Can you please help me ASAP????


THANKS A BUNCH!- Hide quoted text -


- Show quoted text -


Thanks for your help so far! I appreciate it.

Worksheet name is expense. data in cell H2

Thanks!
  #12   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default PLEASE HELP!!! PLEASE!!!

Thanks, but unfortunately it's not original - if you ever watch the movie
"High Road to China", you'll hear it again.

However, I came up with one just recently that, AFIK, is orinal to me. I
was trying to describe the event-driven side of VBA and came up with:
Nothing happens until something happens.
Now, how Zen-like is that? :)

Now I must once again hitch my ass, oops, my ox to the plow and and figure
out how to finalize the help for him.

"Mike H" wrote:

Relax, young grasshopper - the ox is slow, but the earth is patient.

I like that :)

"JLatham" wrote:

Relax, young grasshopper - the ox is slow, but the earth is patient. It
takes time to:
read and comprehend a request, code and test a possible solution, and then
get it all back here for you to use.

I believe the code below will do what you want. It 'intercepts' the normal
workbook save process to do all that you want. You will need to change one
Const value that's set up in it, the path you want it saved into, once you've
copied it into your workbook.

This code works with the Workbook_BeforeSave event, and so it MUST go into a
particular area in the workbook. To get to that area:
Open your workbook.
RIGHT-click on the little Excel icon that is immediately to the left of the
word File in the Excel menu bar. Choose [View Code] from the popup list that
should appear.

Copy the code below and paste it into the code module that was presented to
you when you chose [View Code]. CHANGE the Const savePath to = "your real
path" (but actually put the path in between the quote marks and be sure there
is a path separator (\ for Wintel machines, : for Macs) at the end of that
path). There's an example of a revision to that line of code in the code
below.

Once you've done this properly, each time you try to save the workbook, it
will do as you have asked. The only way to save it somewhere else is going
to be to copy it from your special folder to where ever else you want a copy.

The code:

Private Sub Workbook_BeforeSave(ByVal _
SaveAsUI As Boolean, Cancel As Boolean)
'change this path to the path you want it to end up in
Const savePath = "C:\"

'for example you might change it to:
'Const savePath = _
"C:\Documents and Settings\All Users\Documents\ExcelHelpGiven\_TestFolder\"

Const basicName = "Monthly Expenses "
Static IAmBusy As Boolean
Dim currentDir As String
Dim newName As String

If IAmBusy Then
Exit Sub
End If
IAmBusy = True ' prevent reentry
Application.DisplayAlerts = False
currentDir = CurDir ' so we can restore it later
ChDir savePath ' get ready for the save in proper place
newName = basicName & Format(Now(), "dd-mmm-yyyy") & ".xls"
On Error GoTo CleanupAfterAbort ' just in case!
If Dir$(savePath & newName) < "" Then
'file exists, ask about overwriting
If MsgBox("File:" & vbCrLf & _
savePath & newName & vbCrLf & _
"Already Exists --- Overwrite it?", _
vbYesNo + vbCritical, "Overwrite Old File?") = vbYes Then
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
Else
MsgBox "File Save Cancelled by User"
Cancel = True
GoTo CleanupAfterAbort
End If
Else
'new file, just save it
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
End If
CleanupAfterAbort:
If Err < 0 Then
MsgBox "Error: " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & _
"Took place while trying to save the file!"
Err.Clear
End If
On Error GoTo 0 'reset error trapping
'restore the original default path
ChDir currentDir
Application.DisplayAlerts = True
'reset busy flag
IAmBusy = False
End Sub


"Damil4real" wrote:

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!

  #13   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1,316
Default PLEASE HELP!!! PLEASE!!!

Cool saying about the ox being slow.

However, my favorite Zen sayins it "All I want is nothing."

That came courtesy of Frank Zappa and is not an original of mine.
--
Kevin Backmann


"JLatham" wrote:

Oh - it DOES NOT do ALL that you asked. It doesn't pick up that cell value
that you wanted it to as part of the filename. You'll need to tell us the
name of the worksheet that cell is on and what its address (A1, B9, XX44,
etc) is before we can help with that.


"Damil4real" wrote:

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!

  #14   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,365
Default PLEASE HELP!!! PLEASE!!!

I wasn't sure where you wanted the information from H2 in the workbook name,
so I stuck it in just ahead of the date. Here's the final code. Same
instructions as before - but if you already put code in the workbook, just
delete the old and copy, paste and edit the new.

Private Sub Workbook_BeforeSave(ByVal _
SaveAsUI As Boolean, Cancel As Boolean)
'change this path to the path you want it to end up in
'Const savePath = "C:\"
'for example you might change it to:
Const savePath = _
"C:\Documents and Settings\All Users\Documents\ExcelHelpGiven\_TestFolder\"
Const basicName = "Monthly Expenses"
Static IAmBusy As Boolean
Dim currentDir As String
Dim newName As String
Dim fromCellH2 As Variant

If IAmBusy Then
Exit Sub
End If
IAmBusy = True ' prevent reentry
Application.DisplayAlerts = False
currentDir = CurDir ' so we can restore it later
ChDir savePath ' get ready for the save in proper place

'get whatever is in H2 and put it into
'text format for adding to the filename
If IsEmpty(ThisWorkbook.Worksheets("expense").Range(" H2")) Then
fromCellH2 = " "
Else
fromCellH2 = " " & _
Trim(CStr(ThisWorkbook.Worksheets("expense").Range ("H2"))) & _
" "
End If

newName = basicName & fromCellH2 & _
Format(Now(), "dd-mmm-yyyy") & ".xls"
On Error GoTo CleanupAfterAbort ' just in case!
If Dir$(savePath & newName) < "" Then
'file exists, ask about overwriting
If MsgBox("File:" & vbCrLf & _
savePath & newName & vbCrLf & _
"Already Exists --- Overwrite it?", _
vbYesNo + vbCritical, "Overwrite Old File?") = vbYes Then
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
Else
MsgBox "File Save Cancelled by User"
Cancel = True
GoTo CleanupAfterAbort
End If
Else
'new file, just save it
ThisWorkbook.SaveAs newName
MsgBox "File has been saved as: " & ThisWorkbook.Name
End If
CleanupAfterAbort:
If Err < 0 Then
MsgBox "Error: " & Err.Number & vbCrLf & _
Err.Description & vbCrLf & _
"Took place while trying to save the file!"
Err.Clear
End If
On Error GoTo 0 'reset error trapping
'restore the original default path
ChDir currentDir
Application.DisplayAlerts = True
'reset busy flag
IAmBusy = False
End Sub


"Damil4real" wrote:

How can I get macro to save a workbook to a specific path? And then I
want it to reference a cell in the workbook as part of its file name
when it's saved.

Example:

Save workbook as "Monthly Expenses 1-Sept-08"

The "Monthly Expenses" word is constant, but the date will change
daily.
I want this workbook to be save to in a specific folder in C:\....)
Also a pop-up window should come up asking if user want to overwrite
an already saved file.
If they say yes, then file should be overwritten, and a pop-up window
saying "file saved!" If they say no, then file should not be saved at
all, and a pop-up window saying "file not saved!

Can you please help me ASAP????

THANKS A BUNCH!

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



All times are GMT +1. The time now is 12:40 PM.

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

About Us

"It's about Microsoft Excel"