Word Automation/Printing

Everything in the code below works great except that the Printer Dialog box doesn’t open. I need to allow the users to redirect the printing to another printer besides their default printer. How do I make the printer dialog visible? //FirstDemand CompanyInfo.GET; CompanyInfo.TESTFIELD(“First Notice Path”); CompanyInfo.CALCFIELDS(“Collection Manager Name”,CompanyInfo.“Collection Manager E-Mail”); Cust.GET(custnum); SetCustDateBuckets(Cust); Cust.CALCFIELDS(Cust.“Past 30”,Cust.“Past 60”,Cust.“Past 90”); TotalBalance := Cust.“Past 30” + Cust.“Past 60” + Cust.“Past 90”; IF TotalBalance <= 0 THEN EXIT; TemplateName := CompanyInfo.“First Notice Path”; CLEAR(wdRange); CREATE(wdApp); wdDoc := wdApp.Documents.Add(TemplateName); wdApp.ActiveDocument.Fields.Update; wdApp.Visible := FALSE; // Set Company Address wdRange := wdApp.ActiveDocument.Fields.Item(1).Result; wdRange.Text := CompanyInfo.Address; // Set Company City State, Zip wdRange := wdApp.ActiveDocument.Fields.Item(2).Result; wdRange.Text := CompanyInfo.City + ', ’ + CompanyInfo.State + ’ ’ + CompanyInfo.“ZIP Code”; // Set Company Phone wdRange := wdApp.ActiveDocument.Fields.Item(3).Result; wdRange.Text := CompanyInfo.“Phone No.”; // Set Company Toll-Free Phone wdRange := wdApp.ActiveDocument.Fields.Item(4).Result; wdRange.Text := ‘Toll Free ’ + CompanyInfo.“Toll Free Phone No.”; // Set Company Fax wdRange := wdApp.ActiveDocument.Fields.Item(5).Result; wdRange.Text := ‘Fax ’ + CompanyInfo.“Fax No.”; // Set Collection Manager E-mail wdRange := wdApp.ActiveDocument.Fields.Item(6).Result; wdRange.Text := CompanyInfo.“Collection Manager E-Mail”; // Set Date wdRange := wdApp.ActiveDocument.Fields.Item(7).Result; wdRange.Text := FORMAT(TODAY,0,’ <Day,2>, ‘); // Set Customer Name wdRange := wdApp.ActiveDocument.Fields.Item(8).Result; wdRange.Text := Cust.Name; // Set Customer No. wdRange := wdApp.ActiveDocument.Fields.Item(9).Result; wdRange.Text := Cust.“No.”; // Set Customer Address wdRange := wdApp.ActiveDocument.Fields.Item(10).Result; wdRange.Text := Cust.Address; // Set Customer City, State Zip wdRange := wdApp.ActiveDocument.Fields.Item(11).Result; wdRange.Text := Cust.City + ‘, ’ + Cust.State + ’ ’ + Cust.“ZIP Code”; // Set Total Past Due Balance wdRange := wdApp.ActiveDocument.Fields.Item(12).Result; wdRange.Text := StringFunctions.ConvertDecimalValueToDollars(TotalBalance); // Set 30 Day Balance wdRange := wdApp.ActiveDocument.Fields.Item(13).Result; wdRange.Text := StringFunctions.ConvertDecimalValueToDollars(Cust.“Past 30”) + ’ 30 Days’; // Set 60 Day Balance wdRange := wdApp.ActiveDocument.Fields.Item(14).Result; wdRange.Text := StringFunctions.ConvertDecimalValueToDollars(Cust.“Past 60”) + ’ 60 Days’; // Set 90 Day Balance wdRange := wdApp.ActiveDocument.Fields.Item(15).Result; wdRange.Text := StringFunctions.ConvertDecimalValueToDollars(Cust.“Past 90”) + ’ 90+ Days’; // Set Company Name wdRange := wdApp.ActiveDocument.Fields.Item(16).Result; wdRange.Text := CompanyInfo.Name; // Set Collection Managers Phone Number wdRange := wdApp.ActiveDocument.Fields.Item(17).Result; wdRange.Text := CompanyInfo.“Collection Manager Phone No.”; // Set Collection Manager Name (Script Font) wdRange := wdApp.ActiveDocument.Fields.Item(18).Result; wdRange.Text := CompanyInfo.“Collection Manager Name”; // Set Collection Manager Name wdRange := wdApp.ActiveDocument.Fields.Item(19).Result; wdRange.Text := CompanyInfo.“Collection Manager Name”; // Set Company Name wdRange := wdApp.ActiveDocument.Fields.Item(20).Result; wdRange.Text := CompanyInfo.Name; PrintBackground := false; wdApp.PrintOut(PrintBackground); SaveChanges := FALSE; wdApp.Quit(SaveChanges); CLEAR(wdApp); CLEAR(wdDoc); CLEAR(wdRange);

Hi Bill, Instead of wdApp.PrintOut(…), use wdApp.Dialogs(wdDialogFilePrint).Show, where wdDialogFilePrint = 88. I haven’t done this in Navision yet, only in Word VBA, but it should do the trick in either case.

After adding this, I got the error: A maximum of 0 paramiters must be used when calling this function. So I removed the paramter and received this message: You have specified an unknown variable SHOW

Oh, you have probably encountered the old problem that Navision Automation barfs when too many dot operators (a.b.c…) are used in a single expression. I have experienced this problem on several indeterministic occasions [:p] Try to define a C/AL variable of type Word.Dialogs and another of type Word.Dialog, then use wdDialogs := wdApp.Dialogs; wdDialog := wdDialogs.Item(88); wdDialog.Show; If this still fails, it will at least pinpoint the problem to a single operation. Let me know if it works [:D]

Works great, thanks!

Well, I assumed it was working great [:I] because I saw the printer dialog box. However, nothing ever prints. [:(!]

This is strange - normally, pressing the “OK” button on the printer dialog will start the printing process. At least in VBA. There’s no need for an extra “PrintOut” after the showing of the dialog. [?]