PDA

View Full Version : [SOLVED] Problem with save



gibbo1715
09-28-2005, 09:34 AM
Can anyone tell me why this is not working please

Thanks

Gibbo


Dim todaysdate As Date
Dim Customer As String
Dim Thislocation As String
Customer = Worksheets("Invoice").Range("B11").value
Thislocation = thisdir
' Print and save Button
Application.ScreenUpdating = False
ActiveSheet.Copy
Application.GetSaveAsFilename
Application.DisplayAlerts = False
ActiveWorkbook.Save
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True

Jacob Hilderbrand
09-28-2005, 09:36 AM
Try this:


Dim FName As String
FName = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs FileName:=FName

Bob Phillips
09-28-2005, 09:38 AM
It is a bit hard to say as you don't tell us what is not working, and we don't see where thisdir is defined or what ThisLocation is used for. But ...

GetSaveAsFilename is a function, and you just run it. That is a bit pointless as it returns a value which one would normally use in the code, you don't.


.

gibbo1715
09-28-2005, 09:44 AM
wow, thanks for the extreamy quick reply

Code works as follows


Dim FName As String
' Print and save Button
Application.ScreenUpdating = False
Application.DisplayAlerts = False
ActiveSheet.Copy
FName = Application.GetSaveAsFilename
ActiveWorkbook.SaveAs Filename:=FName
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True
'Print
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True

My only other question is that the Application.GetSaveAsFilename
comes up with the only option in the drop down as all files, how do i default it to xls?

Cheers

Gibbo

P.S. xld, sorry for being vague, long day and wasnt thinking clearly hence the poor explanation

Bob Phillips
09-28-2005, 10:34 AM
Change the filefilter to xls as shown in the VBA help (it uses txt, same principle).

gibbo1715
09-28-2005, 11:09 AM
Thankyou, just the job

Gibbo