in reply to "type mismatch" in Word

If you want to use named parameters with Office and OLE, use a hashref.

$mydoc->SaveAs( {FileName => "$xfn", FileFormat => wdFormatDocument} );