Application.GetSaveAsFilename

  • Thread starter Thread starter mctavish14
  • Start date Start date
M

mctavish14

Major novice requiring assistance.

Using the following for a button (very basic) but whilst it opens as expected (save as) it doesn't actually save.

Sub Xxxxxx_SaveAs()

Application.GetSaveAsFilename


End Sub


I hear it may be a compatibility issue, but if anyone can provide an alternative to solve my problem, it would be most appreciated.

Cheers
 
(e-mail address removed) presented the following explanation :
Major novice requiring assistance.

Using the following for a button (very basic) but whilst it opens as expected
(save as) it doesn't actually save.

Sub Xxxxxx_SaveAs()

Application.GetSaveAsFilename


End Sub


I hear it may be a compatibility issue, but if anyone can provide an
alternative to solve my problem, it would be most appreciated.

Cheers

It does exactly what its name implies; it returns the filename you want
to save as. You actually have to save it using Application.SaveAs and
pass the filename obtained...

Dim vFileToSave As Variant
With Application
vFileToSave = .GetSaveAsFilename
If vFileToSave = False Then Exit Sub '//user cancels
.SaveAs Filename:=vFileToSave
End With 'Application

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
mctavish14 presented the following explanation :






It does exactly what its name implies; it returns the filename you want

to save as. You actually have to save it using Application.SaveAs and

pass the filename obtained...



Dim vFileToSave As Variant

With Application

vFileToSave = .GetSaveAsFilename

If vFileToSave = False Then Exit Sub '//user cancels

.SaveAs Filename:=vFileToSave

End With 'Application



--

Garry



Free usenet access at http://www.eternal-september.org

Classic VB Users Regroup!

comp.lang.basic.visual.misc

microsoft.public.vb.general.discussion

Garry,

Thanks for the reply. Both codes now open the Save As window and populate the File name: field with that of the workbook, but it still does not save to any location you select. You click Save and expect it to have worked, as there's no error or sign that it has not worked, but the file is not there.

The Save as type: field is All Files (*.*) is this an issue?

I'm guessing I need something a lot more complex than my current skills cancater for.
 
The GetSaveAsFilename function includes the path and so is passed to
the Workbook.SaveAs function.

Oops! I see I did not include a ref to the workbook. Sorry about
that...

Dim vFileToSave As Variant

vFileToSave = Application.GetSaveAsFilename
If vFileToSave <> False Then _
ActiveWorkbook.SaveAs Filename:=vFileToSave

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion
 
Back
Top