2010-09-07 10 views
6

मैं जावा से PowerPoint और अन्य Office अनुप्रयोगों को COM कॉल करने के लिए JACOB का उपयोग कर रहा हूं। एक विशेष विंडोज 7 बॉक्स पर मैं अक्सर निम्न संदेश हो रही है, लेकिन हमेशा नहीं:Office 2007 किसी सेवा से JACOB के माध्यम से कॉल किए जाने पर फ़ाइलों को खोलने में असमर्थ है

Source: Microsoft Office PowerPoint 2007 
Description: PowerPoint could not open the file. 

एक्सेल से मैं मिलता है:

ERROR - Invoke of: Open 
Source: Microsoft Office Excel 
Description: Microsoft Office Excel cannot access the file 'c:\marchena\marchena10\work\marchena\batch_58288\input\content_1.xlsx'. There are several possible reasons: 

? The file name or path does not exist. 
? The file is being used by another program. 
? The workbook you are trying to save has the same name as a currently open workbook. 

वर्ड त्रुटि बस है:

VariantChangeType failed 

निम्नलिखित है जो मैं चला रहा हूं, त्रुटि अंतिम पंक्ति से आती है।

 ComThread.InitSTA(); 

     slideApp = new ActiveXComponent("PowerPoint.Application"); 

     Dispatch presentations = slideApp.getProperty("Presentations").toDispatch(); 

     Dispatch presentation = Dispatch.call(presentations, "Open", inputFile.getAbsolutePath(), 
       MsoTriState.msoTrue.getInteger(), // ReadOnly 
       MsoTriState.msoFalse.getInteger(), // Untitled The Untitled parameter is used to create a copy of the presentation. 
       MsoTriState.msoFalse.getInteger() // WithWindow 
     ).toDispatch(); 

मैं सिर्फ ओपन कॉल करने से पहले एक ब्रेकपाइंट डालने की कोशिश की है और फ़ाइल है, और मैं वास्तव में जीयूआई में PowerPoint के साथ खोल सकते हैं लेकिन जब मैं कदम अपवाद फेंक दिया है।

इस मुद्दे के बारे में कष्टप्रद बात यह है कि ऐसा लगता है कि यह लगातार शुरू होता है, लेकिन थोड़ी देर के लिए इसे पोक करने के बाद (उसी कोड को दोबारा शुरू करने के बाद), यह अंततः सफलतापूर्वक पूरा हो जाता है, और उसके बाद कभी भी पुन: प्रयास नहीं करता है।

आगे के शोध में मैंने पाया है कि यह केवल .ppt, .doc और .xls फ़ाइलों के साथ होता है, नहीं .pptx, .docx और .xlsx। और जहां तक ​​मैं कह सकता हूं कि यह फ़ाइल सिस्टम से संबंधित नहीं है (मैंने उन तंत्रों को बदल दिया है जो फ़ाइलों की प्रतिलिपि बनाते हैं और फ़ाइलों को एक अलग फ़ाइल सिस्टम पर डालने का प्रयास करते हैं)।

मैंने अभी देखा है कि यह तब होता है जब जावा एप्लिकेशन सेवा के रूप में चल रहा है, न कि जब मैं कमांड लाइन से catalina.bat start चलाता हूं।

उत्तर

2

क्या यह आपके लिए काम करता है?

import com.jacob.activeX.ActiveXComponent; 
import com.jacob.com.ComThread; 
import com.jacob.com.Dispatch; 
import com.jacob.com.Variant; 

public class PPT { 
    private static final String inputFile = "c:\\learning.ppt"; 
    public static void main(String[] args) { 
     ActiveXComponent slideApp = new ActiveXComponent("PowerPoint.Application"); 
     slideApp.setProperty("Visible", new Variant(true)); 
     ActiveXComponent presentations = slideApp.getPropertyAsComponent("Presentations"); 
     ActiveXComponent presentation = presentations.invokeGetComponent("Open",new Variant(inputFile), new Variant(true)); 
     ComThread.Release(); 
      } 
     } 

अपडेट: इस ग्राहक काम कर रहा है और यह सिर्फ स्वचालन कि समस्या आ रही है है हैं, तो आप देख सकते हैं http://support.microsoft.com/kb/257757 संभावित समस्याओं को देखने के लिए। वहां त्रुटि कोड स्पष्ट रूप से भिन्न हैं, लेकिन यह आपको सभी की समस्या निवारण में मदद कर सकता है।

+0

मुझे लगता है कि का उपयोग कर एक ही त्रुटि मिलती है। यह भी एक सेवा के रूप में चलाता है, इसलिए यह मुखर जानबूझकर था। –

+0

क्या आपका विन 7 बॉक्स x64 या x86 है? यदि यह x64 है, तो क्या आपने 64 बिट JVM को तैनात किया है? –

+0

हां, यह x64 है, 64 बिट जेवीएम और jacob.dll का x64 संस्करण है। –

2

मैं एक ही समस्या (सेवा में याकूब काम नहीं कर रहा है), और यह सहायक पोस्टिंग (Dcomcnfg पर बदल रहा है) था चाल किया:

http://bytes.com/topic/c-sharp/answers/819740-c-service-excel-application-workbooks-open-fails-when-called-service#post3466746

+2

यहां एक आसान फिक्स भी है। व्यवस्थापक के रूप में, निम्न दो फ़ोल्डर्स बनाएं: "सी: \ विंडोज \ SysWOW64 \ config \ systemprofile \ डेस्कटॉप" और "सी: \ विंडोज \ System32 \ config \ systemprofile \ डेस्कटॉप"। आपको शायद केवल एक या दूसरे की आवश्यकता है, लेकिन इसमें दोनों मामलों को 64-बिट ओएस पर शामिल किया गया है। यहां से: [लिंक] (http://bytes.com/topic/c-sharp/answers/819740-c-service-excel-plplication-workbooks-open-fails-when-called-service#post3514712) –

संबंधित मुद्दे