CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Sending text...

  1. #1
    Join Date
    Aug 2001
    Posts
    4

    Sending text...

    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.


  2. #2
    Join Date
    Aug 2000
    Location
    NY, USA
    Posts
    632

    Re: Sending text...

    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


  3. #3
    Join Date
    Feb 2002
    Location
    TN, US
    Posts
    1

    Re: Sending text...

    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


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured