CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2001
    Posts
    7

    Issuing a print command to Wordpad

    How do you get wordpad to print a .txt file from inside a VB program?

    ~~~~~~~~~~~~
    James Fowler

  2. #2
    Join Date
    Jun 2001
    Location
    MO, USA
    Posts
    2,868

    Re: Issuing a print command to Wordpad

    This code will attempt to open the application associated with the .txt file extension and print the specified file. (The default association is notepad, not wordpad)


    option Explicit
    private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (byval hwnd as Long, byval lpOperation as string, byval lpFile as string, byval lpParameters as string, byval lpDirectory as string, byval nShowCmd as Long) as Long
    Const SW_SHOWNORMAL = 1
    private Const SW_HIDE = 0

    private Sub Command1_Click()
    ShellExecute me.hwnd, "print", "C:\Test.txt", vbNullString, vbNullString, SW_SHOWNORMAL
    End Sub






  3. #3
    Join Date
    Sep 2001
    Posts
    7

    Re: Issuing a print command to Wordpad

    Thanks, it worked wonders. =)
    and btw I've associated .txt to wordpad so *shrug*
    Anyhow, thanks for your help. It is apperciated.

    ~~~~~~~~~~~~
    James Fowler

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