#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2003
    Posts
    1
    Rep Power
    0

    Smile How to print MS Word document using C?


    We are trying to print a MS Word document using C program. We can print a text documents, but not the Word document. Everytime we try to print a Word document it try to print as text document. Sample code will be appreciated.

    Thanks,
    Paul.
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,593
    Rep Power
    4207
    Assuming you're using a windoze compiler such as Visual C++ or Borland C++ or Borland C++ Builder, try using this:
    Code:
    #include <shellapi.h>
    
    ...
    ... in your print function ...
    ShellExecute(NULL, "print", "path\\to\\file", NULL, NULL, SW_HIDE);
    You'll also need to add shell32.lib to the list of libraries to link to, if your project doesn't already do this.

    See http://msdn.microsoft.com/library/de...ellexecute.asp for documentation on the ShellExecute function. Hope this helps :)

IMN logo majestic logo threadwatch logo seochat tools logo