1
yukita
COMS not working
  • 2007/2/18 17:04

  • yukita

  • Just popping in

  • Posts: 1

  • Since: 2007/2/18


hi, im new in programmin in php, i was trying a COM example, to generate a report here. Im getting this error message:

Fatal error: Uncaught exception 'com_exception' with message 'Source: Microsoft Word
Description: This file could not be found. (C:\wamp\www\...\html\claimtemplate.doc)' in C:\wamp\www\Clinicflash\Wizards\4214\html\generateinsreport.php:38 Stack trace: #0 C:\wamp\www\Clinicflash\Wizards\4214\html\generateinsreport.php(38): variant->Open('C:\wamp\www\Cli...') #1 {main} thrown in C:\wamp\www\Clinicflash\Wizards\4214\html\generateinsreport.php on line 38

Pleeease help..urgent :(

$template="C:\wamp\www\Clinicflash\Wizards\4214\html\claimtemplate.doc";

$pid = $_POST['patient'];

mysql_select_db($database_conn_clinic, $conn_clinic);
$sql = "select * from patient where Patientid=$pid";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);
// fake form parameters
$pname=$row["Patientname"];
$psurname=$row["Patientsurname"];
$add = $row["Address1"]." ".$row["Address2"];

if ($row["Sex"]=="F")
$sex = "Female";
else
{ $sex = "Male"; }

$dateofbirth=$row["DOB"];
$phone=$row["Phone1"];
$dateregistered=$row["date_of_registration"];
$Durationstay=$_POST['durationstay'];
$cause=$_POST['cause'];
$medicines = $_POST['medicines'];
$fees = $_POST['fees'];
$description=$_POST['description'];
$doctorattenting=$_POST['doctor'];
$date2d=date("d.M.Y");

// start Word
$word=new COM("word.Application") or die("Cannot start MS Word");
// print "Loaded Word version ($word->Version)\n";

$word->Documents->Open($template);


// fill in fields
$word->Application->Run("pname");
$word->Selection->TypeText($pname);

$word->Application->Run("psurname");

$word->Selection->TypeText($psurname);

$word->Application->Run("address");
$word->Selection->TypeText($add);

$word->Application->Run("sex");
$word->Application->Run($sex);


$word->Application->Run("dateodbirth");
$word->Selection->TypeText( $dateofbirth);

$word->Application->Run("phone");
$word->Selection->TypeText($phone);

$word->Application->Run("dateregistered");
$word->Selection->TypeText($dateregistered);

$word->Application->Run("Durationstay");
$word->Selection->TypeText($Durationstay);

$word->Application->Run("cause");
$word->Selection->TypeText($cause);

$word->Application->Run("description");
$word->Selection->TypeText($description);

$word->Application->Run("medicines");
$word->Selection->TypeText($medicines);

$word->Application->Run("totalfee");
$word->Selection->TypeText($fees);

$word->Application->Run("doctorattending");
$word->Selection->TypeText($doctorattenting);

$word->Application->Run("date2d");
$word->Selection->TypeText($date2d);

$ms_word->Documents[1]->SaveAs("sample1.doc");
// wait to quit
$word->Application->ActiveDocument->Saved=True;

// close the application and release the COM object
$word->Quit( );
$word->Release( );
$word = null;

}

Login

Who's Online

267 user(s) are online (123 user(s) are browsing Support Forums)


Members: 0


Guests: 267


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Oct 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits