473,322 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Urgent print problem

I'm about to deploy a program that prints out Word documents. However,
due to licensing issues, we don't actaully have Word 2003 or Office
2003 installed on the machine - only the free Word Viewer (Microsoft
Office Word Viewer 2003).

I'm just wondering if the following should be possible, because it
doesn't appear to work:
assuming with have

<code>
public enum ShowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}

[DllImport("shell32.dll")]
static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);
</code>

then surely, if I want to print the document to WordView (or whatever
application is registered to '.doc' filetype) I would do the following:

<code>
String sFileToPrint = @"C:\Inetpub\wwwroot\119671.doc";
ShellExecute(IntPtr.Zero, "print", sFileToPrint, "", "",
ShowCommands.SW_SHOW);
</code>

This works fine on a machine with Word 2003 installed, but when I put
it on a machine with just Microsoft Office Word Viewer 2003 on it,
nothing happens.

Any ideas anyone?

Thanks

Dave.

May 3 '06 #1
2 1921
Unfortunately wordview doesn't support shell printing. Nor does it support
command line printing. Nor COM objects. About the only thing it seems
capable of is actually clicking "File->Print".

I've made a kludge that makes it work with keyboard emulation, but honestly
I'm ashamed to even ADMIT that, let alone actually use it :-) Although if
you've found another way around the problem I'd love to hear it.

Jim
"Code Monkey" wrote:
I'm about to deploy a program that prints out Word documents. However,
due to licensing issues, we don't actaully have Word 2003 or Office
2003 installed on the machine - only the free Word Viewer (Microsoft
Office Word Viewer 2003).

I'm just wondering if the following should be possible, because it
doesn't appear to work:
assuming with have

<code>
public enum ShowCommands : int
{
SW_HIDE = 0,
SW_SHOWNORMAL = 1,
SW_NORMAL = 1,
SW_SHOWMINIMIZED = 2,
SW_SHOWMAXIMIZED = 3,
SW_MAXIMIZE = 3,
SW_SHOWNOACTIVATE = 4,
SW_SHOW = 5,
SW_MINIMIZE = 6,
SW_SHOWMINNOACTIVE = 7,
SW_SHOWNA = 8,
SW_RESTORE = 9,
SW_SHOWDEFAULT = 10,
SW_FORCEMINIMIZE = 11,
SW_MAX = 11
}

[DllImport("shell32.dll")]
static extern IntPtr ShellExecute(
IntPtr hwnd,
string lpOperation,
string lpFile,
string lpParameters,
string lpDirectory,
ShowCommands nShowCmd);
</code>

then surely, if I want to print the document to WordView (or whatever
application is registered to '.doc' filetype) I would do the following:

<code>
String sFileToPrint = @"C:\Inetpub\wwwroot\119671.doc";
ShellExecute(IntPtr.Zero, "print", sFileToPrint, "", "",
ShowCommands.SW_SHOW);
</code>

This works fine on a machine with Word 2003 installed, but when I put
it on a machine with just Microsoft Office Word Viewer 2003 on it,
nothing happens.

Any ideas anyone?

Thanks

Dave.

May 10 '06 #2
I've had to send keystrokes to wordview because it's the only thing
that seemed to work. Kind of embarassing really! Oh well!

May 15 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
9
by: Adam Right | last post by:
Hi, I am using .Net Framework 2.0 final, and i use .Net printing library to print a document. I use printPreview dialog to print the document but after preview was shown, when i press the...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.