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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open File for Append

Status
Not open for further replies.

vzachin

Technical User
Feb 10, 2006
305
0
0
US
hi,

i want to add today's date to the file i want to append but i don't know how to.

Code:
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")    ' Gets the system object
    Set Sessions = System.Sessions
    Dim Sess0 As Object
    Set Sess0 = System.ActiveSession
    
    IDfile = "C:\\test.txt"    
    Open IDFile for Append as #1
    For i = 1 to 24
    MyArea = Sess0.Screen.GetString (i,1,80)
    Print #1, MyArea
    next i
    Close #1

i tried this
Code:
IDfile = "C:\\test & DATE.txt"
but that doesn't work

any ideas?

thanks
zach
 


Hi,

Don't think you want any kind of SLASH in your date, plus, mind the END QUOTE...
Code:
IDfile = "C:\test" & Format(DATE,"yyyy-mm-dd")


Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
thanks skip to the rescue!
had a senior moment

zach
 


How senior a moment? Mine are in the 67 range.

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
skip,
you got me beat by many years, i'm ashamed to say..;-)

zach
 
VZACHIN
I HAVE A SIMILAR CODE TO YOURS.
HOW WOULD YOU CHANGE THE CODE TO REFERENCE
A FILE THAT'S ALREADY OPEN INSTEAD OF OPENING
A NEW INSTANCE EVERYTIME YOU RUN THE MACRO.

SAMPLE
Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 1000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events

file = "C:\CODE1.xls"
Dim obj as object
Dim objWorkbook as object
Set obj = CreateObject("Excel.Application")
obj.visible = True
obj.workbooks.open file


System.TimeoutValue = OldSystemTimeout
End Sub
 



Please post new questions in a new thread.

Skip,
[sup][glasses]Don't let the Diatribe...
talk you to death![tongue][/sup][sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top