Thread: Date format
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
[email protected] acampbell012@yahoo.com is offline
external usenet poster
 
Posts: 129
Default Date format

On my machine it is breaking on the line:

ActiveWorkbook.SaveAs Filename:=jobsave

"C:\My Documents" directory does not exist on my computer. When I
change jobnumber to point to the temp directory, your macro works.
Does this directory exist on your computer? Will it exist on user's
computers? There are other method of pointing to the My Documents
folder on a given computer.

jobnumber = InputBox("Please enter TIME SHEET file name to
save", " Process Technology", "C:\Temp\" & jobnumber + " " +
jobemployee + " " + (Jobdate))


I also got an error due to JobDate being set as a string variable. Dim
as Variant should fix that.



Oldjay wrote:
Get error 1004 when it tries to save "JobSave" who's value is

"C:\My Documents\1234 Jonn Vandiver 10-2-2006"

Here is the entire macro

oldjay

Private Sub CommandButton4_Click() 'Save time sheet
Dim jobname As String
Dim jobemployee As String
Dim Jobdate As String
Dim jobnumber As String
Dim jobsave As String

Jobdate = Range("D7").Value
Jobdate = Month(Jobdate) & "-" & Day(Jobdate) & "-" &
Year(Jobdate)
jobname = Range("D4")
jobemployee = Range("D2")
jobnumber = Range("D5")

jobnumber = InputBox("Please enter TIME SHEET file name to
save", " Process Technology", "C:\My Documents\" & jobnumber + " " +
jobemployee + " " + (Jobdate))
jobsave = jobnumber & ".XLS"
If jobnumber = "" Then
Range("D1").Select
Range("D3").Select

Else

ActiveWorkbook.SaveAs Filename:=jobsave
ActiveWorkbook.Close
Windows("Process Tech Time Sheet Database.XLS").Activate
Range("D1").Select
Range("D3").Select
End If
End Sub

" wrote:

Add this to your code and use your code as posted.

Dim Jobdate As String
Jobdate = Range("D7").Value
Jobdate = Month(Jobdate) & "-" & Day(Jobdate) & "-" & Year(Jobdate)

Oldjay wrote:
I put the following

jobnumber = InputBox("Please enter TIME SHEET file name to
save", " Process Technology", "C:\My Documents\" & jobnumber + " " +
jobemployee + " " + Month(Jobdate) & "-" & Day(jobdate) & "-" & year(jobdate)

I get a compile error

" wrote:


Try Month(Jobdate) & "-" & Day(jobdate) & "-" & year(jobdate)

Alan


Oldjay wrote:
I am trying to save a file with the date in some other format other than
10/3/06
as this will not allow me to save because of the forward slashs. It tried
changing the format in the input cell but still reverts to the forward slashes

jobdate = Range("D7")

jobnumber = InputBox("Please enter TIME SHEET file name to save", " Process
Technology", "C:\My Documents\" & jobnumber + " " + jobemployee + " " +
jobdate)

Thanks in advance

oldjay