Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pls correct this simple code

Status
Not open for further replies.

bnath005

MIS
Aug 19, 2005
14
US
I get compiler error:

objFile.name = "opxinhdr.txt" & Date()

 
Any chance you could post the error message ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Invalid procedure call or argument.

this is the error message
 
The Date function returns illegal characters for a valid pathname ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
so How to attach today's date at the end of the file?
thanks
nath
 
How would you name the file today ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I want to append todays date as part of the name of the existing file.

I thought the folloiwng code would work.

objFile.name = "opxinhdr.txt" & Date()
 
So, again, what would be the name today ?
Open an Explorer window and do it manually to discover what you can and what you can't do ...

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
objFile.name = "opxinhdr.txt" & 10000*Year(Date) + 100*Month(Date) + Day(Date)

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
strDate = "get it somehow"
strTemp = aFile.Name
'Wscript.Echo aFile.Name
'perhaps should check for . being there...
If InStr(strTemp, ".") Then
strStart = Left(strTemp, InStrRev(strTemp, ".") - 1)
strExt = Right(strTemp, Len(strTemp) - InStrRev(strTemp, ".") + 1)
'perhaps could have got the extension with a FSO.Getxxxx
aFile.Name = strStart & "_" & strDate & strExt
Else
aFile.Name = aFile.Name & strDate
End If

 
Code:
strYear = Year(Date)
strMonth = Month(Date)
If Len(strMonth) = 1 then
  strMonth = "0" & strMonth
End if
strDay = Day(Date)
If Len(strDay) = 1 then
  strDay = "0" & strDay
End if
strOutputFile = "DisabledComputers" & strYear & "-" & strMonth & "-" & strDay & ".htm"

gives name "DisabledComputers2007-01-17.htm
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top