Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to Save As Variable File Name

Hi,

I want to have my macro save as 'active cell' - 'active cell'
quote.xls.

Any idea on how to do this?

I'm trying to save quotes with the customer name and quote number, i.e.
Staples - 20503 Quote.xls where it would find Staples in the cell i'm
on and 20503 in the cell i've moved to one cell to the left of Staples.
Of course, the contents of the cells will be different each time.

I've got everything working for this project except this so I'd really
appreciate the help.

Thanks,

Michele

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 43
Default How to Save As Variable File Name

Here is the code.

The code will take the value from the activecell and the value of the cell
left to the activecell (e.g B1 and A1)

savename = ActiveCell.Value & " - " & ActiveCell.Offset(0, -1).Value & "
Quote.xls"
ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False


" schreef:

Hi,

I want to have my macro save as 'active cell' - 'active cell'
quote.xls.

Any idea on how to do this?

I'm trying to save quotes with the customer name and quote number, i.e.
Staples - 20503 Quote.xls where it would find Staples in the cell i'm
on and 20503 in the cell i've moved to one cell to the left of Staples.
Of course, the contents of the cells will be different each time.

I've got everything working for this project except this so I'd really
appreciate the help.

Thanks,

Michele


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to Save As Variable File Name

Thanks,

I am also going to use the suggestion!

Is there a way to save to the active directory onstead of a fixed drive
path?

Thanks

"Brotha lee" wrote in message
...
Here is the code.

The code will take the value from the activecell and the value of the cell
left to the activecell (e.g B1 and A1)

savename = ActiveCell.Value & " - " & ActiveCell.Offset(0, -1).Value & "
Quote.xls"
ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False


" schreef:

Hi,

I want to have my macro save as 'active cell' - 'active cell'
quote.xls.

Any idea on how to do this?

I'm trying to save quotes with the customer name and quote number, i.e.
Staples - 20503 Quote.xls where it would find Staples in the cell i'm
on and 20503 in the cell i've moved to one cell to the left of Staples.
Of course, the contents of the cells will be different each time.

I've got everything working for this project except this so I'd really
appreciate the help.

Thanks,

Michele




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How to Save As Variable File Name

Depends on what you mean by active directory.

curdir will return the active directory
thisworkbook.path will return the directory of the workbook running the code
activeworkbook.path will return the directory of the activeworkbook

So you could use:
ActiveWorkbook.SaveAs Filename:=curdir & "\" & savename, ....

Or one of those others



FrigidDigit wrote:

Thanks,

I am also going to use the suggestion!

Is there a way to save to the active directory onstead of a fixed drive
path?

Thanks

"Brotha lee" wrote in message
...
Here is the code.

The code will take the value from the activecell and the value of the cell
left to the activecell (e.g B1 and A1)

savename = ActiveCell.Value & " - " & ActiveCell.Offset(0, -1).Value & "
Quote.xls"
ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False


" schreef:

Hi,

I want to have my macro save as 'active cell' - 'active cell'
quote.xls.

Any idea on how to do this?

I'm trying to save quotes with the customer name and quote number, i.e.
Staples - 20503 Quote.xls where it would find Staples in the cell i'm
on and 20503 in the cell i've moved to one cell to the left of Staples.
Of course, the contents of the cells will be different each time.

I've got everything working for this project except this so I'd really
appreciate the help.

Thanks,

Michele



--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default How to Save As Variable File Name

Thanks Dave!!


"Dave Peterson" wrote in message
...
Depends on what you mean by active directory.

curdir will return the active directory
thisworkbook.path will return the directory of the workbook running the
code
activeworkbook.path will return the directory of the activeworkbook

So you could use:
ActiveWorkbook.SaveAs Filename:=curdir & "\" & savename, ....

Or one of those others



FrigidDigit wrote:

Thanks,

I am also going to use the suggestion!

Is there a way to save to the active directory onstead of a fixed drive
path?

Thanks

"Brotha lee" wrote in message
...
Here is the code.

The code will take the value from the activecell and the value of the
cell
left to the activecell (e.g B1 and A1)

savename = ActiveCell.Value & " - " & ActiveCell.Offset(0, -1).Value &
"
Quote.xls"
ActiveWorkbook.SaveAs Filename:= _
"C:\" & savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False


" schreef:

Hi,

I want to have my macro save as 'active cell' - 'active cell'
quote.xls.

Any idea on how to do this?

I'm trying to save quotes with the customer name and quote number,
i.e.
Staples - 20503 Quote.xls where it would find Staples in the cell i'm
on and 20503 in the cell i've moved to one cell to the left of
Staples.
Of course, the contents of the cells will be different each time.

I've got everything working for this project except this so I'd really
appreciate the help.

Thanks,

Michele



--

Dave Peterson





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to Save As Variable File Name

Hi,

I'm using this code and much appreciate it, but now the client wants to
be able to add a bit of text in between the filename. So I've made it
stop before the save with the filename showing and I can add to the
filename, but when it saves it doesn't include what I've added. Here
is the code. Any ideas what I need to do to fix it?

savename = qrPath & ActiveCell.Value & " - " &
ActiveCell.Offset(-3, 2).Value & " Quote.xls"
With Application.FileDialog(msoFileDialogSaveAs)
.InitialFileName = savename
.Show
End With

ActiveWorkbook.SaveAs filename:= _
savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

I'd really appreciate some advice.

Thanks,

Michele

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to Save As Variable File Name

Hi,

The cells are not empty. The filename comes up fine; it's just that
when I modify the filename it doesn't save as that name.

LOL. Why do I show and then saveas....because I don't know what I'm
doing. I thought I could make it stop so I could modify the filename,
but I assume it's in the wrong place. Do you know if I can do what I'm
trying to do?

P.S. - You answered this post at the same time as I sent the second one
believing that no one would see this old post.

Thanks very much,

Michele

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How to Save As Variable File Name

I think I'd dump this section:

With Application.FileDialog(msoFileDialogSaveAs)
.InitialFileName = savename
.Show
End With


And just use the second portion to do the save.

And if there's a chance that the file could already exist:

application.displayalerts = false

ActiveWorkbook.SaveAs filename:= _
savename, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False

application.displayalerts = true

And I think I'd add a msgbox just to verify that savename is actually what you
think it is.

msgbox savename

(I'm not sure I'd rely on the value in the activecell--any cell could be active,
couldn't it?)

wrote:

Hi,

The cells are not empty. The filename comes up fine; it's just that
when I modify the filename it doesn't save as that name.

LOL. Why do I show and then saveas....because I don't know what I'm
doing. I thought I could make it stop so I could modify the filename,
but I assume it's in the wrong place. Do you know if I can do what I'm
trying to do?

P.S. - You answered this post at the same time as I sent the second one
believing that no one would see this old post.

Thanks very much,

Michele


--

Dave Peterson
  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default How to Save As Variable File Name

Hi,

This works, but it doesn't stop and let me update the filename. I'm
okay on the activecell since I move to it just before. The filename is
always correct, except I can't add to it.

You see the file name is "'company' - 'quote#' quote.xls", (were
company and quote# come nicely from cells), but since the customer
often does several quotes the same day for the same company they want
to be able to add something in the middle, i.e. "'company' 'stuff here'
- 'quote#' quote.xls". So I need the saveas to stop and allow filename
updates.

I hope this makes sense.

Thanks,

Michele



  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default How to Save As Variable File Name

I get you.

How about something like this:

Option Explicit
Sub testme01()

Dim SaveName As Variant
Dim qrPath As String

qrPath = "C:\my documents\excel\test\"

SaveName = qrPath & ActiveCell.Value & " - " & _
ActiveCell.Offset(-3, 2).Value & " Quote"

SaveName = Application.GetSaveAsFilename _
(InitialFileName:=SaveName, filefilter:="Excel Files, *.xls")

If SaveName = False Then
MsgBox "Please try later" 'user hit cancel
Else
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=SaveName, _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.DisplayAlerts = True
End If

End Sub

I used my own folder and changed SaveName to a variant--it can return False if
the user hits the cancel button.


wrote:

Hi,

This works, but it doesn't stop and let me update the filename. I'm
okay on the activecell since I move to it just before. The filename is
always correct, except I can't add to it.

You see the file name is "'company' - 'quote#' quote.xls", (were
company and quote# come nicely from cells), but since the customer
often does several quotes the same day for the same company they want
to be able to add something in the middle, i.e. "'company' 'stuff here'
- 'quote#' quote.xls". So I need the saveas to stop and allow filename
updates.

I hope this makes sense.

Thanks,

Michele


--

Dave Peterson
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
Excell2003 (SP-1) File > Save and File > Save As.. grayed out Joe Murphy Excel Discussion (Misc queries) 0 March 9th 05 10:00 PM
Save to Path & Variable file name Otto Moehrbach[_6_] Excel Programming 4 September 2nd 04 10:44 PM
Excel marcos firing on file save as but not file save Andy Excel Programming 1 August 3rd 04 10:34 AM
Save File to Another Directory, but not change Users File Save location Mike Knight Excel Programming 1 May 28th 04 09:06 PM
Using a variable string in a file save path Ron[_13_] Excel Programming 1 October 16th 03 08:29 PM


All times are GMT +1. The time now is 02:53 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"