View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Piranha[_60_] Piranha[_60_] is offline
external usenet poster
 
Posts: 1
Default Add .LOG to .txt file on creation


Hi Leith & Dave,

Leith, I can't get past this line with your code.

Code:
--------------------
If Dir(MyTest99 & ".log") Then
--------------------
I am going to keep
playing with it though

Dave, Exactly what i want. I am going to make the selection
part, to copy the entire selection instead of one cell and i will be
done.

Thx guys, very much appricated.
Dave Peterson Wrote:
I read your post slightly differently. You want .LOG inserted as the
first line
of a .txt file when it is created?

Option Explicit
Sub TxtFile()
Dim rrr As Long
Dim MyTest99 As String
Dim MyData As String
Dim testStr As String

rrr = FreeFile
MyData = Selection.Cells(1).Value
MyTest99 = "E:\backup & testing\test99.txt"

'assumes that the drive/folder exists
testStr = ""
On Error Resume Next
testStr = Dir(MyTest99)
On Error GoTo 0

Open MyTest99 For Append As #rrr
If testStr = "" Then
Print #rrr, ".LOG"
End If
Print #rrr, MyData
Close #rrr
End Sub


A neat way to keep track of time/dates in Text files.

(A hidden feature with notepad if anyone wants to see what it does.)

Piranha wrote:

Hi,
In using this code to create and copy data to a .txt file.

I want to (on the inital creation of the file ONLY) insert .LOG

as the first line.

Code:
--------------------
Sub TxtFile()
Dim rrr
Dim MyTest99
Dim MyData
rrr = FreeFile
MyData = Selection

'On only the inital creation of the txt file, I want .LOG inserted

MyTest99 = "E:\backup & testing\test99.txt"
Open MyTest99 For Append Shared As #rrr
Print #rrr, MyData
Close #rrr
End Sub
--------------------

Any direction appreciated.
Dave

--
Piranha

------------------------------------------------------------------------
Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=20435
View this thread:

http://www.excelforum.com/showthread...hreadid=480975

--

Dave Peterson



--
Piranha
------------------------------------------------------------------------
Piranha's Profile: http://www.excelforum.com/member.php...o&userid=20435
View this thread: http://www.excelforum.com/showthread...hreadid=480975