Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Specifically - I am trying to send a .DOC file to a FAX using C#.NET Office Automation (COM Microsoft Word 11.0 Object Library), so far I have the following:

 

Word.ApplicationClass wordApp = null;
private bool SendFax()
{
object missingValue = Type.Missing; 
object myTrue = true;
object oFaxFile = sFaxFile;

wordApp = new Word.ApplicationClass();
Word.Document doc = wordApp.Documents.Open(ref oFaxFile,
	ref missingValue, ref missingValue, ref missingValue,
	ref missingValue, ref missingValue, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue);

FaxOutDoc(doc);

doc.Close(ref missingValue, ref missingValue, ref missingValue);
return true;
}

private bool FaxOutDoc(Word.Document doc)
{
object myTrue = true; 
object myFalse = false; 
object missingValue = Type.Missing; 
object range = Word.WdPrintOutRange.wdPrintCurrentPage; 
object items = Word.WdPrintOutItem.wdPrintDocumentContent; 
object copies = "1"; 
object pages = "1"; 
object pageType = Word.WdPrintOutPages.wdPrintAllPages; 

doc.PrintOut(ref myTrue, ref myFalse, ref range, 
	ref missingValue, ref missingValue, ref missingValue, 
	ref items, ref copies, ref pages, ref pageType, ref myFalse,
	ref myTrue, ref missingValue,  ref myFalse, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue); 

return true;
}

 

My problem is pretty simple - when I run this code I am unable to select which PRINTER I want to print to, it seems to automatically send it to the default Printer defined in Windows.

So, what I need to do is:

a) Select the FAX PRINTER (as opposed to the default printer), I don't force the user to change defaults when using this application

b) Define the Fax Properties (such as Phone Number, etc...) so the user isn't prompted to fill it in

 

Is there anyway to automate this in C#.NET Office Automation using the COM object?

Thanks,

  • 3 years later...
Posted (edited)

Hi

You don't actually need to specify the printer in the PrintOut command, instead you can set it at the Word Application level:

wordApp = new Word.ApplicationClass();
WordApp.ActivePrinter = YourFaxPrinter

 

If you want to specify the Tray you would use:

wordApp = new Word.ApplicationClass();
wordApp.ActivePrinter = "YourFaxPrinter"

Word.Document doc = wordApp.Documents.Open(ref oFaxFile,
	ref missingValue, ref missingValue, ref missingValue,
	ref missingValue, ref missingValue, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue, 
	ref missingValue, ref missingValue, ref missingValue);
doc.PageSetup.FirstPageTray = "TrayName"

Not sure how to specify the other fax properties though.

Edited by WaddellG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...