C
clarke.jonathan
Hey guys,
Well my very first post in the forum, but I've been a lurker for a long
long long time. Anyhow I hope that someone can help me with this
problem I've been having.
Im attempting to update a word document via Java. I'm currently using
the JACOB api from sourceforge.net and I've about 90% of the
application completed.
My aim is to update a built in property field within a certain word
document and then save it.
I currently have the application enabled to do the following:
1. Open test.doc
2. Retrieve the value of the property field i.e "Author"
3. Save the test.doc
4. Close the test.doc
What I wish to do is to write to the property field i.e "Author"="new
value"
The problem is that javadocs for the JACOB project are not very
informative and although the examples are fantastic they do show me how
to update / write to property fields.
String filename=""; //The path and name of the file
ActiveXComponent wordObjectX; //The ActiveX Object
Dispatch cProperties; //Custom Property
setCustomProperty("testVariable", "newValue");
public void setCustomProperty(String customPropertyName, String aValue)
{
try
{
//Make the update here!
Dispatch.put(cProperties, customPropertyName,aValue);
}
catch (ComException e)
{
e.printStackTrace();
}
}
com.jacob.com.ComFailException: Can't map name to dispid: testVariable
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:833)
at com.jacob.com.Dispatch.invoke(Dispatch.java:512)
at com.jacob.com.Dispatch.put(Dispatch.java:791)
at wordWriter.setCustomProperty(wordWriter.java:195)
at testMain.main(testMain.java:34)
I hope that someone here could just give me a sample function call
about how it could be done! Basically what its saying is that it
cannot find the dispid: testVariable. The funny thing is that I have
no problem reading the value from the word document however I can't
write to the thing at all. This is the part that is wrong:
Dispatch.put(cProperties, customPropertyName,aValue);
Any suggestions?
Thanks in advance,
Well my very first post in the forum, but I've been a lurker for a long
long long time. Anyhow I hope that someone can help me with this
problem I've been having.
Im attempting to update a word document via Java. I'm currently using
the JACOB api from sourceforge.net and I've about 90% of the
application completed.
My aim is to update a built in property field within a certain word
document and then save it.
I currently have the application enabled to do the following:
1. Open test.doc
2. Retrieve the value of the property field i.e "Author"
3. Save the test.doc
4. Close the test.doc
What I wish to do is to write to the property field i.e "Author"="new
value"
The problem is that javadocs for the JACOB project are not very
informative and although the examples are fantastic they do show me how
to update / write to property fields.
the following error message:From my understanding it would be something like this but Im getting
String filename=""; //The path and name of the file
ActiveXComponent wordObjectX; //The ActiveX Object
Dispatch cProperties; //Custom Property
setCustomProperty("testVariable", "newValue");
public void setCustomProperty(String customPropertyName, String aValue)
{
try
{
//Make the update here!
Dispatch.put(cProperties, customPropertyName,aValue);
}
catch (ComException e)
{
e.printStackTrace();
}
}
com.jacob.com.ComFailException: Can't map name to dispid: testVariable
at com.jacob.com.Dispatch.invokev(Native Method)
at com.jacob.com.Dispatch.invokev(Dispatch.java:833)
at com.jacob.com.Dispatch.invoke(Dispatch.java:512)
at com.jacob.com.Dispatch.put(Dispatch.java:791)
at wordWriter.setCustomProperty(wordWriter.java:195)
at testMain.main(testMain.java:34)
I hope that someone here could just give me a sample function call
about how it could be done! Basically what its saying is that it
cannot find the dispid: testVariable. The funny thing is that I have
no problem reading the value from the word document however I can't
write to the thing at all. This is the part that is wrong:
Dispatch.put(cProperties, customPropertyName,aValue);
Any suggestions?
Thanks in advance,