Help with getsaveasfilename

G

Guest

Hi
I have the following code and MyStr = todays date which I have dimmed
previously

If (fso.FolderExists("D:\Documents and Settings\All Users\Documents"))
Then
Workbooks.Open Filename:="D:\Documents and Settings\All
Users\Documents\Forms.xls"
Dim fileSaveName
fileSaveName = Application.GetSaveAsFilename(["D:\Documents and
Settings\All Users\Documents\"] & MyStr, _
fileFilter:="All Files (*.xls), *.xls")
If fileSaveName <> False Then
MsgBox "Save the incident forms for this incident as " & fileSaveName
End If
ActiveSheet.SaveAs fileSaveName

However I need the user to enter the filename and then have it also attach
to the filename they have chosen what is in MyStr and I am unsure how to do
this now.

For Example the file will currently save as
D:\Documents and Settings\All Users\Documents\040607\name user calls file
when prompted

and I want it to save as
D:\Documents and Settings\All Users\Documents\040607\040607+name user calls
file.

Can anyone help please
 
B

Bob Phillips

Const sPath = "C:\Documents and Settings\All Users\Documents"
Dim fileSaveName
Dim iPos As Long
If (fso.FolderExists(sPath)) Then
Workbooks.Open Filename:=sPath & "Forms.xls"
fileSaveName = Application.GetSaveAsFilename(sPath & myStr, _
fileFilter:="All Files (*.xls), *.xls")
If fileSaveName <> False Then
iPos = InStrRev(fileSaveName, ".")
If iPos > 0 Then
fileSaveName = Left(fileSaveName, iPos - 1) & "-" &
Format(myStr, "yyyymmdd") & ".xls"
MsgBox "Save the incident forms for this incident as " &
fileSaveName
ActiveSheet.SaveAs fileSaveName
End If
End If
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)
 
G

Guest

Thanks very much Bob...works a treat.

Bob Phillips said:
Const sPath = "C:\Documents and Settings\All Users\Documents"
Dim fileSaveName
Dim iPos As Long
If (fso.FolderExists(sPath)) Then
Workbooks.Open Filename:=sPath & "Forms.xls"
fileSaveName = Application.GetSaveAsFilename(sPath & myStr, _
fileFilter:="All Files (*.xls), *.xls")
If fileSaveName <> False Then
iPos = InStrRev(fileSaveName, ".")
If iPos > 0 Then
fileSaveName = Left(fileSaveName, iPos - 1) & "-" &
Format(myStr, "yyyymmdd") & ".xls"
MsgBox "Save the incident forms for this incident as " &
fileSaveName
ActiveSheet.SaveAs fileSaveName
End If
End If
End If

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

Jo said:
Hi
I have the following code and MyStr = todays date which I have dimmed
previously

If (fso.FolderExists("D:\Documents and Settings\All Users\Documents"))
Then
Workbooks.Open Filename:="D:\Documents and Settings\All
Users\Documents\Forms.xls"
Dim fileSaveName
fileSaveName = Application.GetSaveAsFilename(["D:\Documents and
Settings\All Users\Documents\"] & MyStr, _
fileFilter:="All Files (*.xls), *.xls")
If fileSaveName <> False Then
MsgBox "Save the incident forms for this incident as " &
fileSaveName
End If
ActiveSheet.SaveAs fileSaveName

However I need the user to enter the filename and then have it also attach
to the filename they have chosen what is in MyStr and I am unsure how to
do
this now.

For Example the file will currently save as
D:\Documents and Settings\All Users\Documents\040607\name user calls file
when prompted

and I want it to save as
D:\Documents and Settings\All Users\Documents\040607\040607+name user
calls
file.

Can anyone help please
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top