ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   SaveAs Dialog comes up twice??? (https://www.excelbanter.com/excel-programming/383851-saveas-dialog-comes-up-twice.html)

chemicals

SaveAs Dialog comes up twice???
 
I am trying to force the user to always save the workbook as a newly named
file into a specific folder. My problem is that the Save As dialog comes up
twice???? Here's my code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Check for Save versus SaveAs
If SaveAsUI Then
SaveAsFile
CreateShortCut
End If
End Sub

Sub SaveAsFile()
Dim strDocName As String
Const FilePath As String = "H:\ProdDev\Client\"

ChDrive FilePath
ChDir FilePath
strDocName = Application.GetSaveAsFilename
If strDocName < "False" Then
ActiveWorkbook.SaveAs Filename:=strDocName
End If
End Sub




Tom Ogilvy

SaveAs Dialog comes up twice???
 
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Check for Save versus SaveAs
If SaveAsUI Then
SaveAsFile
CreateShortCut
Cancel = True
End If
End Sub

--
Regards,
Tom Ogilvy



"chemicals" wrote:

I am trying to force the user to always save the workbook as a newly named
file into a specific folder. My problem is that the Save As dialog comes up
twice???? Here's my code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Check for Save versus SaveAs
If SaveAsUI Then
SaveAsFile
CreateShortCut
End If
End Sub

Sub SaveAsFile()
Dim strDocName As String
Const FilePath As String = "H:\ProdDev\Client\"

ChDrive FilePath
ChDir FilePath
strDocName = Application.GetSaveAsFilename
If strDocName < "False" Then
ActiveWorkbook.SaveAs Filename:=strDocName
End If
End Sub




chemicals

SaveAs Dialog comes up twice???
 
MUCH OBLIGED Tom!

"Tom Ogilvy" wrote:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Check for Save versus SaveAs
If SaveAsUI Then
SaveAsFile
CreateShortCut
Cancel = True
End If
End Sub

--
Regards,
Tom Ogilvy



"chemicals" wrote:

I am trying to force the user to always save the workbook as a newly named
file into a specific folder. My problem is that the Save As dialog comes up
twice???? Here's my code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Check for Save versus SaveAs
If SaveAsUI Then
SaveAsFile
CreateShortCut
End If
End Sub

Sub SaveAsFile()
Dim strDocName As String
Const FilePath As String = "H:\ProdDev\Client\"

ChDrive FilePath
ChDir FilePath
strDocName = Application.GetSaveAsFilename
If strDocName < "False" Then
ActiveWorkbook.SaveAs Filename:=strDocName
End If
End Sub




joel

SaveAs Dialog comes up twice???
 
I think you need to change this line from < to =

If strDocName = "False" Then

"chemicals" wrote:

I am trying to force the user to always save the workbook as a newly named
file into a specific folder. My problem is that the Save As dialog comes up
twice???? Here's my code:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
'Check for Save versus SaveAs
If SaveAsUI Then
SaveAsFile
CreateShortCut
End If
End Sub

Sub SaveAsFile()
Dim strDocName As String
Const FilePath As String = "H:\ProdDev\Client\"

ChDrive FilePath
ChDir FilePath
strDocName = Application.GetSaveAsFilename
If strDocName < "False" Then
ActiveWorkbook.SaveAs Filename:=strDocName
End If
End Sub





All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com