Using VBA to write to Notepad

  reddwarfcrew 20:13 04 Apr 07
Locked

Hi, I have some VBA code in Access that writes to Word, but I'd prefer to write to notepad if possible as the code slows right down when it opens Word.

Has anyone got any suggestions? My code is:

Set objWord = CreateObject("word.application")
Set objWord = GetObject(, "word.application")
objWord.Documents.Add
objWord.Visible = True
objWord.Selection.TypeText Text:=searchDB
objWord.ChangeFileOpenDirectory "J:\PCS\"
objWord.ActiveDocument.SaveAs fileName:="searchDB.js", FileFormat:=wdFormatText
objWord.ActiveDocument.Close wdSaveChanges = False

  VoG II 20:20 04 Apr 07

This is how to do write to a .TXT file in Excel VBA - Access should be similar:

Sub MyOutput()
Dim iMyFreeFile As Integer
Dim string1 As String
Dim var1
string1 = "hello"
var1 = 3

' get a free file number
iMyFreeFile = FreeFile

' open the text file - please note this replaces the file
Open "c:\xltext.txt" For Output As #iMyFreeFile

' write whatever you want

Write #iMyFreeFile, string1, var1
' as long as you write on one line, the data is comma delimited

' if you add another write statement, the data will be on the next line
Write #iMyFreeFile, string1, var1

' now close the file
Close #iMyFreeFile
End Sub

  reddwarfcrew 20:29 04 Apr 07

thats a great help.

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…