Dim strThisTime As String

strThisTime = Format(Now, "mm_dd_yyyy_____Hh_mm_ss")




Is there any possibility that strThisTime needs to be declared as a variant instead of a string ? Doesn't the use of Format() make it work ok ? When I say possibility, I mean it works 50 or 60 times, but on the 61st time the routine is called, the file name is bad ?


NOTE: strThisTime is used as a file name with & .txt appended as below.

Set txtfile = fso.CreateTextFile("C:\CES\XRF_Control\Data_Files\" & strThisTime & ".txt", True)


I'm getting an intermittent fatal error from the FSO. Error NO. -2147023446 ( Invalid code I believe )