So Paperclip, here is the new and ,I hope, right, code.
As one allready told, the Help fonction helps, but i does not tell us how te
declare our variable.
The var_FullPath must be a variant instead and cannot be a string.
The string value output depends on the Excel's language version.
So clicking on the cancel button results in my system in a string 'onwaar'
which is Dutch for 'false'. Changing the string into a variant, makes the
whole thing independent from the language version.
If one clicks the cancel button, the variant var_FullPath becomes a boolean.
.. If one does otherwise, i.e. if one fills in the file-name textbox, the
output is a string. The textbox does not accept empty strings or string
containing spaces only, so no code has to be written for that.
Let's finish the whole thing with a Beatles' quote: and in the end the love
you take is equal to the love you make. Cheers!
Sub cmdCancel_Click()
Dim var_FullPath As Variant
On Error Resume Next
Do
Err.Clear
var_FullPath = Application.GetSaveAsFilename(initialfilename:="", _
fileFilter:="Excel Workbook (*.xls), *.xls")
If var_FullPath <> False Then
ActiveWorkbook.SaveAs var_FullPath
If Err.Number <> 0 Then
MsgBox "File has not been saved. Try again" & Chr(13) &
Err.Description _
, vbExclamation, Err.Number & "Error Message'"
End If
End If
Loop Until Err.Number = 0
Unload Me
End Sub
"paperclip" wrote:
>
> Thanks for the help so far guys...
>
> As Tom pointed out Peter's code has an error in it insomuch as once a
> filename is chosen it brings up another error box. Is there anyway to
> correct this?
>
> Alternatively I was thinking if it was possible to code the cancel
> button to save the file with a pre-determined filename to the users
> desktop automatically or alternatively their C: drive.
>
> Is there anyway this can be done?
>
> Regards.
>
>
> --
> paperclip
> ------------------------------------------------------------------------
> paperclip's Profile: http://www.excelforum.com/member.php...o&userid=32219
> View this thread: http://www.excelforum.com/showthread...hreadid=566739
>
>
Bookmarks