View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default Application.GetSaveAsFilename problem

I don't understand what characters are variable and which are just plain old
strings, but maybe this will give you an idea.

Private Sub PanicSwitch_Click()
Dim AUserFile As Variant
Dim InitFileName as string

Month7Select = Month7.Value
MonthRSelect = MonthR.Value
WeekSelect = Week.Value
NameSelect = AName.Value
CenterSelect = Center.Value

Cells(1, 25) = Month7Select
Cells(1, 1) = MonthRSelect
Cells(2, 1) = WeekSelect
Cells(1, 2) = NameSelect
Cells(2, 2) = CenterSelect

me.hide

initfilename = "C:\somepath\Center C&A PF " _
& monthrselect & "YR Wk" & nameselect & ".xls"

Auserfile = Application.GetSaveAsFilename(InitialFileName:=Ini tFileName, _
filefilter:="Excel files, *.xls")

if auserfile = false then
'user hit cancel
else
ThisWorkbook.SaveAs Filename:=AUserFile
end if

'still unload no matter what?
unload me
End Sub

Is "NotSoFast" the name of the userform that owns this code?

If yes, then the Me keywords (the userform that owns the code) should work ok.

If no, I screwed up your intent.

Bishop wrote:

I have a userform with a button that does the following:

Private Sub PanicSwitch_Click()
Dim AUserFile As Variant
Month7Select = Month7.Value
MonthRSelect = MonthR.Value
WeekSelect = Week.Value
NameSelect = AName.Value
CenterSelect = Center.Value
Cells(1, 25) = Month7Select
Cells(1, 1) = MonthRSelect
Cells(2, 1) = WeekSelect
Cells(1, 2) = NameSelect
Cells(2, 2) = CenterSelect
Unload NotSoFast

AUserFile = Application.GetSaveAsFilename(???
ThisWorkbook.SaveAs Filename:=AUserFile
End Sub

I'm trying to set the InitialFilename parameter as follows:
Center C&A PF Month YR Wk # analyst initials

The user will select Center, Month and Wk # in the userform. We have a
specific filenaming protocol so and I need to match it. Here's an example:
Say John Smith is in the userform. He'll select his name as John Smith, his
Center as GSO, his Month as April, his Week as Week 3. I need to somehow
use this information to set up InitialFilename. Here's what it should look
like:

GSO C&A PF Apr 09 wk 3 js

Here's another example to make it clear: Say Grace Henriques is in the
form. She'll select her name as Grace Henriques, her Center as VHeathrow,
her Month as December, her Week as Week 1. This is what her filename should
save as:

VHeathrow C&A PF Dec 09 wk1 gh

I imagine the syntax will look something like this:

AUserFile = Application.GetSaveAsFilename(CenterSelect & " C&A PF " &
MonthRSelect & " 09 " & WeekSelect & "NameSelect", additional parameters etc)

But as you can see from the file naming protocol I only need the first 3
letters of the month, I need the week to show as "wk1", "wk2" etc, and I only
need the the users initials on the end. Any advice?


--

Dave Peterson