Uncaught exception 'com_exception' Microsoft Word












0














We made the copy from one server to another (Apache), and the following instructions no longer work, we have tried various guides but they do not work




Error code: Fatal error: Uncaught exception 'com_exception' with
message 'Source: Microsoft Word Description: This command is not
available because no document is open




We Have




  • Microsoft Office 2007

  • Windows Server


The code:



    $word = new COM("Word.Application") or die("Unable to instantiate Word");

$word->visible=1;

$wordDocument=$word->Documents->Open($_SERVER['DOCUMENT_ROOT'].$PATH."/modelli_doc/ModificheCDC1.docx");


$bookmarkname = "mese";

$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);


The exception is the line with ActiveDocument
Any solution?










share|improve this question
























  • You assign the document you open to a variable $wordDocument - why don't you use it: $objBookmark = $wordDocument->Bookmarks($bookmarkname); ? Does that still give the same error? If you look at the Word application (you do make it visible?) is the document open?
    – Cindy Meister
    Nov 21 at 9:36










  • $objBookmark = $wordDocument->Bookmarks($bookmarkname) Fatal error: Call to a member function Bookmarks() on a non-object. No is not open Thanks
    – Vazel
    Nov 21 at 9:42










  • Then you need to trouble-shoot the file path being passed to the Open method. Is it valid? Are you able to open the document manually in Word from this location? Does the code have permissions to access this location (since you mention it's changed)?
    – Cindy Meister
    Nov 21 at 9:53










  • Yes is valid, yes i can open document manually. "Does the code have permissions to access this location (since you mention it's changed)", how i can verify?
    – Vazel
    Nov 21 at 9:54












  • I don't know how to verify (no experience with your programing environment). Something you might try is to record a macro when opening manually and compare the file path Word records with what you're using. Also try running the recorded macro and see if that's successful.
    – Cindy Meister
    Nov 21 at 9:57
















0














We made the copy from one server to another (Apache), and the following instructions no longer work, we have tried various guides but they do not work




Error code: Fatal error: Uncaught exception 'com_exception' with
message 'Source: Microsoft Word Description: This command is not
available because no document is open




We Have




  • Microsoft Office 2007

  • Windows Server


The code:



    $word = new COM("Word.Application") or die("Unable to instantiate Word");

$word->visible=1;

$wordDocument=$word->Documents->Open($_SERVER['DOCUMENT_ROOT'].$PATH."/modelli_doc/ModificheCDC1.docx");


$bookmarkname = "mese";

$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);


The exception is the line with ActiveDocument
Any solution?










share|improve this question
























  • You assign the document you open to a variable $wordDocument - why don't you use it: $objBookmark = $wordDocument->Bookmarks($bookmarkname); ? Does that still give the same error? If you look at the Word application (you do make it visible?) is the document open?
    – Cindy Meister
    Nov 21 at 9:36










  • $objBookmark = $wordDocument->Bookmarks($bookmarkname) Fatal error: Call to a member function Bookmarks() on a non-object. No is not open Thanks
    – Vazel
    Nov 21 at 9:42










  • Then you need to trouble-shoot the file path being passed to the Open method. Is it valid? Are you able to open the document manually in Word from this location? Does the code have permissions to access this location (since you mention it's changed)?
    – Cindy Meister
    Nov 21 at 9:53










  • Yes is valid, yes i can open document manually. "Does the code have permissions to access this location (since you mention it's changed)", how i can verify?
    – Vazel
    Nov 21 at 9:54












  • I don't know how to verify (no experience with your programing environment). Something you might try is to record a macro when opening manually and compare the file path Word records with what you're using. Also try running the recorded macro and see if that's successful.
    – Cindy Meister
    Nov 21 at 9:57














0












0








0







We made the copy from one server to another (Apache), and the following instructions no longer work, we have tried various guides but they do not work




Error code: Fatal error: Uncaught exception 'com_exception' with
message 'Source: Microsoft Word Description: This command is not
available because no document is open




We Have




  • Microsoft Office 2007

  • Windows Server


The code:



    $word = new COM("Word.Application") or die("Unable to instantiate Word");

$word->visible=1;

$wordDocument=$word->Documents->Open($_SERVER['DOCUMENT_ROOT'].$PATH."/modelli_doc/ModificheCDC1.docx");


$bookmarkname = "mese";

$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);


The exception is the line with ActiveDocument
Any solution?










share|improve this question















We made the copy from one server to another (Apache), and the following instructions no longer work, we have tried various guides but they do not work




Error code: Fatal error: Uncaught exception 'com_exception' with
message 'Source: Microsoft Word Description: This command is not
available because no document is open




We Have




  • Microsoft Office 2007

  • Windows Server


The code:



    $word = new COM("Word.Application") or die("Unable to instantiate Word");

$word->visible=1;

$wordDocument=$word->Documents->Open($_SERVER['DOCUMENT_ROOT'].$PATH."/modelli_doc/ModificheCDC1.docx");


$bookmarkname = "mese";

$objBookmark = $word->ActiveDocument->Bookmarks($bookmarkname);


The exception is the line with ActiveDocument
Any solution?







php apache exception ms-word com






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 9:33









Cindy Meister

14.1k102134




14.1k102134










asked Nov 21 at 9:28









Vazel

1




1












  • You assign the document you open to a variable $wordDocument - why don't you use it: $objBookmark = $wordDocument->Bookmarks($bookmarkname); ? Does that still give the same error? If you look at the Word application (you do make it visible?) is the document open?
    – Cindy Meister
    Nov 21 at 9:36










  • $objBookmark = $wordDocument->Bookmarks($bookmarkname) Fatal error: Call to a member function Bookmarks() on a non-object. No is not open Thanks
    – Vazel
    Nov 21 at 9:42










  • Then you need to trouble-shoot the file path being passed to the Open method. Is it valid? Are you able to open the document manually in Word from this location? Does the code have permissions to access this location (since you mention it's changed)?
    – Cindy Meister
    Nov 21 at 9:53










  • Yes is valid, yes i can open document manually. "Does the code have permissions to access this location (since you mention it's changed)", how i can verify?
    – Vazel
    Nov 21 at 9:54












  • I don't know how to verify (no experience with your programing environment). Something you might try is to record a macro when opening manually and compare the file path Word records with what you're using. Also try running the recorded macro and see if that's successful.
    – Cindy Meister
    Nov 21 at 9:57


















  • You assign the document you open to a variable $wordDocument - why don't you use it: $objBookmark = $wordDocument->Bookmarks($bookmarkname); ? Does that still give the same error? If you look at the Word application (you do make it visible?) is the document open?
    – Cindy Meister
    Nov 21 at 9:36










  • $objBookmark = $wordDocument->Bookmarks($bookmarkname) Fatal error: Call to a member function Bookmarks() on a non-object. No is not open Thanks
    – Vazel
    Nov 21 at 9:42










  • Then you need to trouble-shoot the file path being passed to the Open method. Is it valid? Are you able to open the document manually in Word from this location? Does the code have permissions to access this location (since you mention it's changed)?
    – Cindy Meister
    Nov 21 at 9:53










  • Yes is valid, yes i can open document manually. "Does the code have permissions to access this location (since you mention it's changed)", how i can verify?
    – Vazel
    Nov 21 at 9:54












  • I don't know how to verify (no experience with your programing environment). Something you might try is to record a macro when opening manually and compare the file path Word records with what you're using. Also try running the recorded macro and see if that's successful.
    – Cindy Meister
    Nov 21 at 9:57
















You assign the document you open to a variable $wordDocument - why don't you use it: $objBookmark = $wordDocument->Bookmarks($bookmarkname); ? Does that still give the same error? If you look at the Word application (you do make it visible?) is the document open?
– Cindy Meister
Nov 21 at 9:36




You assign the document you open to a variable $wordDocument - why don't you use it: $objBookmark = $wordDocument->Bookmarks($bookmarkname); ? Does that still give the same error? If you look at the Word application (you do make it visible?) is the document open?
– Cindy Meister
Nov 21 at 9:36












$objBookmark = $wordDocument->Bookmarks($bookmarkname) Fatal error: Call to a member function Bookmarks() on a non-object. No is not open Thanks
– Vazel
Nov 21 at 9:42




$objBookmark = $wordDocument->Bookmarks($bookmarkname) Fatal error: Call to a member function Bookmarks() on a non-object. No is not open Thanks
– Vazel
Nov 21 at 9:42












Then you need to trouble-shoot the file path being passed to the Open method. Is it valid? Are you able to open the document manually in Word from this location? Does the code have permissions to access this location (since you mention it's changed)?
– Cindy Meister
Nov 21 at 9:53




Then you need to trouble-shoot the file path being passed to the Open method. Is it valid? Are you able to open the document manually in Word from this location? Does the code have permissions to access this location (since you mention it's changed)?
– Cindy Meister
Nov 21 at 9:53












Yes is valid, yes i can open document manually. "Does the code have permissions to access this location (since you mention it's changed)", how i can verify?
– Vazel
Nov 21 at 9:54






Yes is valid, yes i can open document manually. "Does the code have permissions to access this location (since you mention it's changed)", how i can verify?
– Vazel
Nov 21 at 9:54














I don't know how to verify (no experience with your programing environment). Something you might try is to record a macro when opening manually and compare the file path Word records with what you're using. Also try running the recorded macro and see if that's successful.
– Cindy Meister
Nov 21 at 9:57




I don't know how to verify (no experience with your programing environment). Something you might try is to record a macro when opening manually and compare the file path Word records with what you're using. Also try running the recorded macro and see if that's successful.
– Cindy Meister
Nov 21 at 9:57

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408902%2funcaught-exception-com-exception-microsoft-word%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53408902%2funcaught-exception-com-exception-microsoft-word%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'