Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Both writing a text file and opening that text file are quite simple:
To write to text: Sub StringToTextFile(ByVal txtFile As String, _ ByVal strString As String) Dim hFile As Long hFile = FreeFile Open txtFile For Output As hFile 'Write #hFile, strString 'this will make start- and end quotes Print #hFile, strString; Close #hFile End Sub To open the text file: Sub OpenAsText(strPath As String) Dim lRetVal As Long 'can do without this On Error GoTo CANTOPEN If bFileExists(strPath) Then lRetVal = Shell("write" & " " & """" & strPath & """", 1) Else MsgBox "There is no valid file path supplied", , "opening text file" End If Exit Sub CANTOPEN: MsgBox "Could not open" & _ vbCrLf & vbCrLf & _ strPath, , "opening text file" End Sub Function bFileExists(ByVal sFile As String) As Boolean Dim lAttr As Long On Error Resume Next lAttr = GetAttr(sFile) bFileExists = (Err.Number = 0) And ((lAttr And vbDirectory) = 0) On Error GoTo 0 End Function RBS "stuart" wrote in message ... Hi, I'm writing a macro using VBA in Excel and to get the output from the macro to be written in Notepad rather than an Excel worksheet. How do I do this, if it's at all possible? Thanks. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Writing to notepad file | Excel Discussion (Misc queries) | |||
Is there a way to do this without using notepad? | Excel Programming | |||
NotePad | Excel Programming | |||
notepad in excel | Excel Programming | |||
opening and writing into notepad | Excel Programming |