aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes Calling Word macro from java getting read only popup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Calling Word macro from java getting read only popup" Watch "Calling Word macro from java getting read only popup" New topic
Author

Calling Word macro from java getting read only popup

Vishal Alhat
Greenhorn

Joined: Jun 05, 2007
Posts: 8
Hi,
I am calling word macro from java program with the help of JACOB(14) lib. It actually calling macro in loop, in every iteration it calls macro once. Where it actually bookmarks paragraphs in given document .
For every call of macro it opens given word document bookmark paragraph and closes it , I know this may not be ideal way , but now its a scenario
When we try to run two or more instances of java program which calls macro, simultaneously it gives error for word document that the "document is locked by user do you want to open it in read Only mode "

I am not able to identify it is problem with java or word macro or JACOB lib.


Also i wanna know when we call native method JVM waits for native method to complete or not???

Thanks in advance!!!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

That's not a problem at all: two users can't modify an open Word document at the same time.
Vishal Alhat
Greenhorn

Joined: Jun 05, 2007
Posts: 8
ohhh sorry forgot to mentioned, for two different document it is giving error.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
Are Java code, JACOB and Word macro all thread-safe? I'm not familiar with this setup, but it sounds like the type of issue that might happen if code is not thread-safe.


Ping & DNS - updated with new look and Ping home screen widget
Vishal Alhat
Greenhorn

Joined: Jun 05, 2007
Posts: 8
for (int i = 0; i < docParts.size(); i++) {
d = (DocPart) docParts.get(i);
Variant value = null;

value = Dispatch.call(oWord, "Run", new
Variant("NewMacros.ParagraphBookmark"),new
Variant(d.paraStartIndex),new
Variant(d.paraEndIndex),new
Variant(document_directory+SOURCE_DOC_REF_WORD),new
Variant("BK_DP_"+tmpDpID));


This is code snapshot, "Dispatch.call(" is call for JACOB which actually uses native method to bookmark document paragraph.
I wanna know that if we call native method from java, does it wait for native to complete?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39578
    
  27
I would think so, but that's easy to test, no?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Calling Word macro from java getting read only popup
 
Similar Threads
AJAX Issue - Messages got lost...
Formatting Word ducuments using Jacob
calling a word macro from java
Problem with Ms Word
Returning array To Method