View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
GS GS is offline
external usenet poster
 
Posts: 364
Default xl copy cell content to NotePad

Here's a function I got from Francesco Balena that you could try. It takes
two arguments, the text and the filename. I use this a lot in a cnc program
file manager add-in that reads/writes partial or entire lines, blocks,
...including find & replace text. <requires separate read function The add-in
happens to use Notepad as a file editor, so I know the text displays exactly
as desired, -with no surprises.

Function WriteFileContents(vText As Variant, szFileName As String)
' Writes the edited contents back to the file
' This function actually creates a new file with new text, overwriting the
original file

Const sSource As String = "WriteFileContents()"

Dim iNum As Integer, bOpen As Boolean

On Error GoTo ErrHandler

iNum = FreeFile() 'Get the next file number

'Read the entire file
Open szFileName For Binary As #iNum
bOpen = True 'If we got here the file opened without error
Put #iNum, , vText 'Dump the contents into the file

ErrHandler:
'We're done with the file so close it
If bOpen Then Close #iNum

End Function

HTH
Regards,
Garry