C
Code Monkey
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.
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.