Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default HOW DO I USE THE GETSAVEASFILENAME METHOD?

When using the InitialFilename argument, I would like to combine the contents
of several cells and a text constant to form the InitialFilename. For
example, I want the filename to be a string consisting of: "C" + "cell1" +
"cell2". If the contents of "cell1" are '50000' and "cell2" are the text
letter 'A', then the InitialFilename argument would be: C50000A.xls. What is
the code for this in Excel 2003 VBA?

Mike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default HOW DO I USE THE GETSAVEASFILENAME METHOD?

Dim myFileName As Variant

With ActiveWorkbook.Worksheets("Sheet1")
myFileName = "C:\my documents\excel\c" _
& .Range("A1").Value _
& .Range("b1").Value & ".xls"
End With

myFileName = Application.GetSaveAsFilename(InitialFileName:=myF ileName, _
filefilter:="Excel files,*.xls")

If myFileName = False Then
'user hit cancel
Exit Sub
End If


or maybe:

With ActiveWorkbook.Worksheets("Sheet1")
myFileName = "C:\my documents\excel\c" _
& format(.Range("A1").Value, "00000") _
& .Range("b1").Value & ".xls"
End With

if you have to format that number.


Mike wrote:

When using the InitialFilename argument, I would like to combine the contents
of several cells and a text constant to form the InitialFilename. For
example, I want the filename to be a string consisting of: "C" + "cell1" +
"cell2". If the contents of "cell1" are '50000' and "cell2" are the text
letter 'A', then the InitialFilename argument would be: C50000A.xls. What is
the code for this in Excel 2003 VBA?

Mike


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default HOW DO I USE THE GETSAVEASFILENAME METHOD?

Dave,

I wrote the following code. It does bring up the "Save As" dialog box and
does have the recommended file name that I wanted, however, when I hit the
"Save" button, the file does not actually get written to the hard drive. The
dialog box simply unloads. Why is the file not actually being saved? Thanks
for your help so far.


Private Sub OKButton_Click()
Dim myname As Variant
With ActiveWorkbook.Worksheets("Summary Sheet")
myname = "C" & .Range("h12").Value & .Range("k12").Value & ".xls"
End With
Ans = MsgBox("Please save your work to the P:\ Drive under the CostSell
Subdirectory with the filename: 'C[S.O. #][Revision Letter]', i.e. C50000A.",
vbOKCancel + vbExclamation, "Save Your Work")
If Ans = vbOK Then myname =
Application.GetSaveAsFilename(InitialFileName:=myn ame, filefilter:="Excel
Files,*.xls")
If myname = False Then
Exit Sub
End If
Unload UserForm3
End Sub

"Dave Peterson" wrote:

Dim myFileName As Variant

With ActiveWorkbook.Worksheets("Sheet1")
myFileName = "C:\my documents\excel\c" _
& .Range("A1").Value _
& .Range("b1").Value & ".xls"
End With

myFileName = Application.GetSaveAsFilename(InitialFileName:=myF ileName, _
filefilter:="Excel files,*.xls")

If myFileName = False Then
'user hit cancel
Exit Sub
End If


or maybe:

With ActiveWorkbook.Worksheets("Sheet1")
myFileName = "C:\my documents\excel\c" _
& format(.Range("A1").Value, "00000") _
& .Range("b1").Value & ".xls"
End With

if you have to format that number.


Mike wrote:

When using the InitialFilename argument, I would like to combine the contents
of several cells and a text constant to form the InitialFilename. For
example, I want the filename to be a string consisting of: "C" + "cell1" +
"cell2". If the contents of "cell1" are '50000' and "cell2" are the text
letter 'A', then the InitialFilename argument would be: C50000A.xls. What is
the code for this in Excel 2003 VBA?

Mike


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default HOW DO I USE THE GETSAVEASFILENAME METHOD?

GetSaveAsFilename only prompts the user for a name and path for the saved
file: it does not save the file. The next step is to save the file using
SaveAs...

Tim.

--
Tim Williams
Palo Alto, CA


"Mike" wrote in message
...
Dave,

I wrote the following code. It does bring up the "Save As" dialog box and
does have the recommended file name that I wanted, however, when I hit the
"Save" button, the file does not actually get written to the hard drive.

The
dialog box simply unloads. Why is the file not actually being saved?

Thanks
for your help so far.


Private Sub OKButton_Click()
Dim myname As Variant
With ActiveWorkbook.Worksheets("Summary Sheet")
myname = "C" & .Range("h12").Value & .Range("k12").Value & ".xls"
End With
Ans = MsgBox("Please save your work to the P:\ Drive under the

CostSell
Subdirectory with the filename: 'C[S.O. #][Revision Letter]', i.e.

C50000A.",
vbOKCancel + vbExclamation, "Save Your Work")
If Ans = vbOK Then myname =
Application.GetSaveAsFilename(InitialFileName:=myn ame, filefilter:="Excel
Files,*.xls")
If myname = False Then
Exit Sub
End If
Unload UserForm3
End Sub

"Dave Peterson" wrote:

Dim myFileName As Variant

With ActiveWorkbook.Worksheets("Sheet1")
myFileName = "C:\my documents\excel\c" _
& .Range("A1").Value _
& .Range("b1").Value & ".xls"
End With

myFileName = Application.GetSaveAsFilename(InitialFileName:=myF ileName,

_
filefilter:="Excel files,*.xls")

If myFileName = False Then
'user hit cancel
Exit Sub
End If


or maybe:

With ActiveWorkbook.Worksheets("Sheet1")
myFileName = "C:\my documents\excel\c" _
& format(.Range("A1").Value, "00000") _
& .Range("b1").Value & ".xls"
End With

if you have to format that number.


Mike wrote:

When using the InitialFilename argument, I would like to combine the

contents
of several cells and a text constant to form the InitialFilename. For
example, I want the filename to be a string consisting of: "C" +

"cell1" +
"cell2". If the contents of "cell1" are '50000' and "cell2" are the

text
letter 'A', then the InitialFilename argument would be: C50000A.xls.

What is
the code for this in Excel 2003 VBA?

Mike


--

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
Help with getsaveasfilename Jo Excel Discussion (Misc queries) 2 June 5th 07 12:41 AM
GetSaveasFileName Libby Excel Programming 1 September 8th 05 07:45 PM
GetSaveAsFileName Greg Hadrych Excel Programming 1 July 29th 04 12:52 AM
GetSaveAsFilename method Donna Brooks Excel Programming 6 January 27th 04 10:37 PM
GetSaveAsFilename Anand Attavane Excel Programming 2 October 22nd 03 01:21 AM


All times are GMT +1. The time now is 01:42 AM.

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"