473,394 Members | 1,794 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

word properties

Hai frnds i am new to php i am having following problems in my coding... 1.Actually i am opening word document with com object and storing it in textarea. 2.when content gets opened in textarea i am editing that content and saving the document 3.actually when i edited that file and done save after that if i open word document then file properties->custom the old content getting removed i wannt to retain that even if i edited the word document..please do the needful i am using below code
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  
  4. $filename = 'C:/xampp/htdocs/mts/sites/default/files/a.doc';
  5. //echo $filename;
  6. if(isset($_REQUEST['Save'])){
  7. $somecontent = stripslashes($_POST['somecontent']);
  8. // Let's make sure the file exists and is writable first.
  9. if (is_writable($filename)) {
  10.  
  11. // In our example we're opening $filename in append mode.
  12. // The file pointer is at the bottom of the file hence
  13. // that's where $somecontent will go when we fwrite() it.
  14. if (!$handle = fopen($filename, 'w')) {
  15. echo "Cannot open file ($filename)";
  16. exit;
  17. }
  18.  
  19. // Write $somecontent to our opened fi<form action="" method="get"></form>le.
  20. if (fwrite($handle, $somecontent) === FALSE) {
  21. echo "Cannot write to file ($filename)";
  22. exit;
  23. }
  24.  
  25. echo "Success, wrote ($somecontent) to file ($filename) <a href=".$_SERVER['PHP_SELF']."> - Continue - ";
  26.  
  27. fclose($handle);
  28.  
  29. } else {
  30. echo "The file $filename is not writable";
  31. }
  32. }
  33. else{
  34. // get contents of a file into a string
  35. $handle = fopen($filename, "r");
  36. $somecontent = fread($handle, filesize($filename));
  37. $word = new COM("word.application") or die ("Could not initialise MS Word object.");
  38. $word->Documents->Open(realpath("$filename"));
  39.  
  40. // Extract content.
  41. $somecontent = (string) $word->ActiveDocument->Content;
  42.  
  43. //echo $somecontent;
  44.  
  45. $word->ActiveDocument->Close(false);
  46.  
  47. $word->Quit();
  48. $word = null;
  49. unset($word);
  50. fclose($handle);
  51. }
  52. ?>
  53.  
  54. <h6>Edit file --------><? $filenam=explode("/",$filename);$filename=$filename[7]; echo $filename ;?></h6>
  55. <form name="form1" method="post" action="">
  56. <p>
  57. <textarea name="somecontent" cols="100" rows="20"><? echo $somecontent ;?></textarea>
  58. </p>
  59.  
  60. <div style='padding-left:250px;'><input type="submit" name="Save" value="Save"></div>
  61. </p>
  62. </form>
  63.  
  64. <?
  65. }
  66.  
  67. ?>
May 24 '10 #1
0 951

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Ken | last post by:
Hi, I've written a C# app in VS .Net 2003 that gets and sets custom/summary properties of Word documents by selecting a directory and get/setting values using BuiltInDocumentProperties and...
24
by: downwitch | last post by:
Hi, I know this has been covered here and in the .public groups, but it seems like it's been a while, especially around here, so I just thought I'd ask again to see if anyone has figured out a...
8
by: Asma | last post by:
Dear Sir, I am trying to find a way to open a Word document using C language and read the text of word doc into a variable. (Turbo C on Dos 6.0). Can anyone please tell me which libraries in...
10
by: Sunny | last post by:
Hi, I have an old problem which I couldn't solve so far. Now I have found a post in that group that gave me an idea, but I can not fully understand it. The problem is: I'm trying to use a...
4
by: Daniel | last post by:
Hello, i have a problem with the word automation from c#. First, i want to mention, that i don't have any dependencies from word in my c#-project, i want to use the system.reflection model to...
3
by: Charles Law | last post by:
Word has a property BuiltinDocumentProperties, which (in VBA) returns a DocumentProperties collection. In VB.NET, using Word automation, it returns a _ComObject. I have tried to cast this to...
4
by: =?Utf-8?B?QmVuamFtaW5vNQ==?= | last post by:
Apologies if this is the wrong forum. I normally post in the Word Programming group, but this seemed like more of a VB.Net question. I'm moving code from VBA over to Visual Studio Express 2005...
1
by: rguruprasad | last post by:
Hi, I would like to write a program which add/remove/Modify the properties of a MS Word document like the Author, Title, Creation date etc. using Java. Please let me know how i can do that. ...
0
by: =?Utf-8?B?UHJvYmk=?= | last post by:
I´m trying to do some Word Automation in C# in the Custom Properties so far found very few ways to do that I made the following : Type Prop = Type.GetTypeFromProgID("Word.CustopParoperties");...
0
by: Tim Rowe | last post by:
2008/10/7 Peter Wang <peterwang@vip.qq.com>: Why use VBA? It's actually not a straight choice. VBA is pretty much all that's available if you're doing it from *inside* Word, it's not available...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.