Question : NotePad

I need to open notepad.exe and output a variable to it (In VBA).

Is there any way to achieve this task?

I'm using Microsoft Access 2010 on a win 7 machine.

Any kind of help is much appreciated.

Answer : NotePad

Here is code to create blank text file (just comment out the lines for adding text, and add the MS Scripting Runtime library to your VBA references)
From here:
http://www.ozgrid.com/forum/showthread.php?t=58283&page=1


Sub WriteTextFile()
     ' Writing a text file using File System Object in VBA
     ' This code requires a reference (In the VBE Tools > References) to Microsoft Scripting Runtime
     
    Dim FSO As FileSystemObject
    Dim FSOFile As TextStream
    Dim FilePath As String
    Dim NoOfLoop As Integer
     
    FilePath = "c:\WriteTest.txt" ' create a test.txt file or change this
     
    Set FSO = New FileSystemObject
         ' opens  file in write mode
        Set FSOFile = FSO.OpenTextFile(FilePath, 2, True)
'        'loop round adding lines
'        For NoOfLoop = 1 To 10
'            ' write your code here
'            FSOFile.WriteLine (" I am writing line " & NoOfLoop)
'        Next NoOfLoop
       
        FSOFile.Close

End Sub

Again, armed with all of this knowledge, I am sure you can make your system work as specified.

;-)

JeffCoachman
Random Solutions  
 
programming4us programming4us