Save Text file

  • Thread starter Stephen sjw_ost
  • Start date
S

Stephen sjw_ost

I am using the code below to write some lines of text into a text file so I
can keep some of my data organized. The code will open notepad, as it should,
and write to it, as it should, but I want to be able to save the file
automaticaly as well when the code finishes.
Currently I have to wait for the code to finish and then close notepad
manually, at which point I can save, but I want it all automatic.

Open notepad, write to notepad, save and close notepad.

As always, any help is appreciated.

Function writesqlini()
Dim rs As Recordset, db As Database, npad
Dim line1, line2, line3, all As String

Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM t_SQLdata")
npad = Shell("C:\WINNT\NOTEPAD.exe", 1)
AppActivate npad, True

rs.MoveFirst
Do Until rs.EOF
line1 = rs!dlrspec
line2 = rs!master & rs!ip & rs!port
line3 = rs!query & rs!ip & rs!port
' all = line1 & vbCrLf & _
' line2 & vbCrLf & _
' line3

SendKeys line1, True
SendKeys "~", True
SendKeys line2, True
SendKeys "~", True
SendKeys line3, True
SendKeys "~~", True

rs.MoveNext
Loop
SendKeys "{BKSP}{BKSP}", True

End Function
 
D

Daniel Pineault

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top