ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   using saveas twice will be error,savecopyas don't use also,why? (https://www.excelbanter.com/excel-programming/350531-using-saveas-twice-will-error-savecopyas-dont-use-also-why.html)

iBirdman

using saveas twice will be error,savecopyas don't use also,why?
 
Option Explicit
Sub save()


Dim path As String
Dim MainTitle As String 'have got "new item",po and rekey po and so on.
Dim EndChar As String
Dim VendorNum As String
Dim VendorName As String
Dim ItemNum As String
Dim ItemDesc As String
Dim FinalFileName As String
Dim fName



'first fill the follow of value.
MainTitle = "NEW ITEM"
EndChar = Format(Date, "MMDDYY")
VendorNum = Range("A1")
VendorName = ""
ItemNum = Range("B1")
ItemDesc = ""
FinalFileName = MainTitle & VendorName & "_" & VendorNum & "_" & ItemDesc &
"_" & ItemNum & "_" & EndChar
path = ThisWorkbook.path & "\" & FinalFileName

'save file

On Error GoTo 123
ThisWorkbook.SaveAs (path)
Exit Sub
123:
fName = Application.GetSaveAsFilename
If fName = False Then Exit Sub
ThisWorkbook.SaveAs (fName) 'use twice will be error,why?
End Sub




All times are GMT +1. The time now is 05:25 AM.

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