Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Using GetSaveAs

I want users to be able to save a file by prompting them
with a suggested file name but allowing them to overwrite
it with and alternative, but I would also like the usual
Excel prompt to appear The filename Newname already exists
etc, so that they can change their option. I was trying to
use the undernoted code but this does not bring up the
usual alerts. How do I get the alerts to appear?

Application.GetSaveAsFilename Initialfilename:=Newname

TIA
Ron
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Using GetSaveAs

I just ask myself:

Option Explicit
Sub testme99()

Dim resp As Long
Dim sFilename As Variant
Dim newName As String

newName = "C:\my documents\excel\book1.xls"

sFilename = Application.GetSaveAsFilename( _
InitialFileName:=newName)
If sFilename = False Then Exit Sub

If Dir(sFilename) < "" Then
resp = MsgBox(prompt:="It exists, Overwrite?", Buttons:=vbYesNo)
If resp = vbNo Then
Exit Sub
End If
End If

application.displayalerts = false
'file|saveas stuff here
application.displayalerts = true

End Sub

But if you want the standard excel stuff, you may just want to display that
dialog:

Sub testme09()
Dim newName As String
newName = "C:\my documents\excel\book1.xls"
Application.Dialogs(xlDialogSaveAs).Show arg1:=newName
End Sub

I like the first better. It seems more straight forward to catch if they hit
the cancel key. (But you could check later, too.)

Ron McCormick wrote:

I want users to be able to save a file by prompting them
with a suggested file name but allowing them to overwrite
it with and alternative, but I would also like the usual
Excel prompt to appear The filename Newname already exists
etc, so that they can change their option. I was trying to
use the undernoted code but this does not bring up the
usual alerts. How do I get the alerts to appear?

Application.GetSaveAsFilename Initialfilename:=Newname

TIA
Ron


--

Dave Peterson

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
No Success with GetSaveAs D.Parker Excel Discussion (Misc queries) 5 April 20th 05 02:16 PM


All times are GMT +1. The time now is 05:54 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"