Board index » delphi » Office 97 - Word Printing Error

Office 97 - Word Printing Error

I get a 'type mismatch' error when I try to have word print a document my
application just created.  Can anyone help with why I'm getting this error.
 A snippet of my code follows.

procedure .....
var
   Background, Append, Range, OutputFileName, PFrom, PTo, Item :
OleVariant;
   Copies, Pages, PageType, PrintToFile, Collate : OleVariant;
   ActivePrinterMacGX, ManualDuplexPrint : OleVariant;

begin
      Background := true;      Append := true;      Range :=
wdPrintAllDocument;
      OutputFileName := '';      PFrom := '';      PTo := '';
      Item := wdPrintDocumentContent;      Copies := 1;      Pages := '';
      PageType := wdPrintAllPages;      PrintToFile := false;
      Collate := false;      ActivePrinterMacGX := '';    
ManualDuplexPrint := '';

      wDoc.PrintOut(Background, Append, Range, OutputFileName, PFrom,
               PTo, Item, Copies, Pages, PageType, PrintToFile, Collate,
               ActivePrinterMacGX, ManualDuplexPrint);
end;

 

Re:Office 97 - Word Printing Error


Quote
"Lynn Higdon" <L...@ASTARinc.com> wrote:
>I get a 'type mismatch' error when I try to have word print a document my
>application just created.  Can anyone help with why I'm getting this error.
> A snippet of my code follows.

>procedure .....
>var
>   Background, Append, Range, OutputFileName, PFrom, PTo, Item :
>OleVariant;
>   Copies, Pages, PageType, PrintToFile, Collate : OleVariant;
>   ActivePrinterMacGX, ManualDuplexPrint : OleVariant;

>begin
>      Background := true;      Append := true;      Range :=
>wdPrintAllDocument;
>      OutputFileName := '';      PFrom := '';      PTo := '';
>      Item := wdPrintDocumentContent;      Copies := 1;      Pages := '';
>      PageType := wdPrintAllPages;      PrintToFile := false;
>      Collate := false;      ActivePrinterMacGX := '';    
>ManualDuplexPrint := '';

>      wDoc.PrintOut(Background, Append, Range, OutputFileName, PFrom,
>               PTo, Item, Copies, Pages, PageType, PrintToFile, Collate,
>               ActivePrinterMacGX, ManualDuplexPrint);
>end;

You could try:

    ManualDuplexPrint := null;

I believe that this is required since:
ManualDuplexPrint   Optional Variant. Not used in the U.S. English
version of Microsoft Word. {from VBA Word8 help file}

You may have to set Pages := '1';  {or other print range}
otherwise you will get a 'This is not a valid print range' exception.

PS. I haven't checked all your other variables.

Regards,
Chris Roberts

Re:Office 97 - Word Printing Error


I'll give that a try.  Thanks!!

Chris Roberts <cdrobert_nos...@ctel.com.au> wrote in article
<34764be6.1757...@forums.borland.com>...

Quote
> "Lynn Higdon" <L...@ASTARinc.com> wrote:

> >I get a 'type mismatch' error when I try to have word print a document
my
> >application just created.  Can anyone help with why I'm getting this
error.
> > A snippet of my code follows.

> >procedure .....
> >var
> >   Background, Append, Range, OutputFileName, PFrom, PTo, Item :
> >OleVariant;
> >   Copies, Pages, PageType, PrintToFile, Collate : OleVariant;
> >   ActivePrinterMacGX, ManualDuplexPrint : OleVariant;

> >begin
> >      Background := true;      Append := true;      Range :=
> >wdPrintAllDocument;
> >      OutputFileName := '';      PFrom := '';      PTo := '';
> >      Item := wdPrintDocumentContent;      Copies := 1;      Pages :=
'';
> >      PageType := wdPrintAllPages;      PrintToFile := false;
> >      Collate := false;      ActivePrinterMacGX := '';    
> >ManualDuplexPrint := '';

> >      wDoc.PrintOut(Background, Append, Range, OutputFileName, PFrom,
> >               PTo, Item, Copies, Pages, PageType, PrintToFile, Collate,
> >               ActivePrinterMacGX, ManualDuplexPrint);
> >end;

> You could try:

>     ManualDuplexPrint := null;

> I believe that this is required since:
> ManualDuplexPrint   Optional Variant. Not used in the U.S. English
> version of Microsoft Word. {from VBA Word8 help file}

> You may have to set Pages := '1';  {or other print range}
> otherwise you will get a 'This is not a valid print range' exception.

> PS. I haven't checked all your other variables.

> Regards,
> Chris Roberts

Other Threads