View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
iBirdman iBirdman is offline
external usenet poster
 
Posts: 1
Default 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