ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   MsgBox for filename and static path (https://www.excelbanter.com/excel-programming/377021-msgbox-filename-static-path.html)

BillB

MsgBox for filename and static path
 
I have a file at the end of a macro that needs to be saved as an
employees name and a date to a directory I want to define.

I want to use a MsgBox and ask for Name and Date. How do I then
convert the entry in the msgbox and join it to my path so the file is
saved with the right name and in the right place?


Charles Chickering

MsgBox for filename and static path
 
Dim nm as string
dim dt as string
nm = InputBox("Please Enter your name")
dt = InputBox("Please Enter a date" & vbCrLf & "Use format mm-dd-yyyy")
If not isdate(format(var1,"mm-dd-yyyy")) Then
Msgbox "Invalid Date, exiting macro"
Exit Sub
End if
ActiveWorkbook.SaveAs Filename:=YourStaticPath & nm & dt & ".xls"
--
Charles Chickering

"A good example is twice the value of good advice."


"BillB" wrote:

I have a file at the end of a macro that needs to be saved as an
employees name and a date to a directory I want to define.

I want to use a MsgBox and ask for Name and Date. How do I then
convert the entry in the msgbox and join it to my path so the file is
saved with the right name and in the right place?



chemicals

MsgBox for filename and static path
 
Try something like this...


Dim MyValue As String
Dim filepath
Dim filename

MyValue = InputBox("Enter your name", "Name Entry Dialog")
fileame = MyValue & "_" & Date

Filepath = "c:\whereever\" & filename

ThisWorkBook.SaveAs Filename:=Filepath

ThisWorkBooK.Close


"BillB" wrote:

I have a file at the end of a macro that needs to be saved as an
employees name and a date to a directory I want to define.

I want to use a MsgBox and ask for Name and Date. How do I then
convert the entry in the msgbox and join it to my path so the file is
saved with the right name and in the right place?




All times are GMT +1. The time now is 10:36 AM.

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