Click to See Complete Forum and Search --> : Sending text...


Noob 4 ever
August 27th, 2001, 02:11 PM
I would like to make a simple program that opens notepad with one command button, then with another button it sends text to it from a text box. So I could keep clicking the button to keep sending different text messages to it. I don't know if I'm making my situation clear or not, but anything will help.

vchapran
August 27th, 2001, 03:42 PM
With Word it's very easy. In new project add reference to MS Word through Project>References. Then place 1 text box and 2 buttons on the form and paste this code:

option Explicit
public objWord as Word.Application

private Sub Command1_Click()
set objWord = new Word.Application
With objWord
.Visible = true
.WindowState = wdWindowStateNormal
.Documents.Add Template:= _
"C:\Program Files\Microsoft Office\Templates\Normal.dot", NewTemplate:= _
false
End With
Command1.Enabled = false
End Sub

private Sub Command2_Click()
With objWord
.Selection.TypeText Text:=Text1.Text
.Selection.TypeParagraph
End With
End Sub



If Normal.dot file located in different location, than on my machine, then change the path.
This is just a beginning. You also need to write the code to save the file, to close it, to destroy Word object and some more things. But this sample gives you an idea.
HTH
Vlad

afk
February 13th, 2002, 10:56 PM
I am currently writing an application with a similar function. Can this function be done without using the Word app? I would like my app to be all-inclusive.

Any help in this matter would be greatly appreciated...
Andy