Fordraiders
asked on
inputbox for helping create a unique excel file name. vba
excel 2003 vba..
The following code helps create a unique file name using date and time.
What I need:
I need the information from an inputbox to go in front of the information below.for the filename. (less the date stuff)..
Thanks
fordraiders
Public Sub NewNameSaveAs()
Dim oldwkbk As String
Dim newdate As String
'Workbook.SaveAs ...
oldwkbk = ThisWorkbook.Name
Application.DisplayAlerts = False
'Use the Date
newdate = Format$(Date, "yyyy-mm-dd")
ActiveWorkbook.SaveAs "C:\Program Files\Dm\" & newdate & "_" & oldwkbk
Application.DisplayAlerts = True
End Sub
The following code helps create a unique file name using date and time.
What I need:
I need the information from an inputbox to go in front of the information below.for the filename. (less the date stuff)..
Thanks
fordraiders
Public Sub NewNameSaveAs()
Dim oldwkbk As String
Dim newdate As String
'Workbook.SaveAs ...
oldwkbk = ThisWorkbook.Name
Application.DisplayAlerts = False
'Use the Date
newdate = Format$(Date, "yyyy-mm-dd")
ActiveWorkbook.SaveAs "C:\Program Files\Dm\" & newdate & "_" & oldwkbk
Application.DisplayAlerts = True
End Sub
Here is an example:
Public Sub NewNameSaveAs()
Dim oldwkbk As String
' Get new file name prefix
strPrefix = InputBox(Prompt:="File name prefix please.", _
Title:="Enter File Name Prefix", Default:="Prefix")
If strPrefix = "Prefix" Or strPrefix = vbNullString Then
Exit Sub
Else
' Workbook.SaveAs ...
oldwkbk = ThisWorkbook.Name
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs "C:\Program Files\Dm\" & strPrefix & "_" & oldwkbk
Application.DisplayAlerts = True
End If
End Sub
Here is some more information on InputBox: http://www.ozgrid.com/VBA/inputbox.htm
ASKER
guys, as usual , I have not explained myself correctly.
Sorry,
I'm wanting to (no visual) to open this workbook.
Workbooks.Open _
Filename:="C:\Program Files\Oss\Export\Cross\Exp ort_Crs_KS -Data_Coll ection_Tem plate_D-50 _.xls"
put the input box here..
then do a filesaveas on the workbook
"Export_Crs_KS-Data_Collec tion_Templ ate_D-50_. xls"
The code I posted is something I use for a simliar routine...
Thanks
fordraiders
Sorry,
I'm wanting to (no visual) to open this workbook.
Workbooks.Open _
Filename:="C:\Program Files\Oss\Export\Cross\Exp
put the input box here..
then do a filesaveas on the workbook
"Export_Crs_KS-Data_Collec
The code I posted is something I use for a simliar routine...
Thanks
fordraiders
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
ThANKS
Thomas
Open in new window
If you don't want the date at all, use:
Open in new window