• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Calling Word macro from java getting read only popup

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!!!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That's not a problem at all: two users can't modify an open Word document at the same time.
 
Vishal Alhat
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ohhh sorry forgot to mentioned, for two different document it is giving error.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Vishal Alhat
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would think so, but that's easy to test, no?
 
We begin by testing your absorbancy by exposing you to this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic