Page 1 of 1

Bookmark renaming

PostPosted: Fri Apr 06, 2012 9:45 pm
by Nanocom
Hi,

I'm trying to find out how to rename every bookmark of a .docx (by for example adding a "_1" to every bookmark name). how would you do that?

Re: Bookmark renaming

PostPosted: Mon Apr 09, 2012 9:27 pm
by sureshbabubv
Hi Nanocom,

Can you please try in the following manner


Employee1.sName="rajesh";
Employee Employee2 = new Employee();
Employee2.sName="mahesh";
Employee Employee3 = new Employee();
Employee3.sName="rakesh";
Employee Employee4 = new Employee();
Employee4.sName="romesh";
Employee Employee5 = new Employee();
Employee5.sName="bhups";

ArrayList alEmployee = new ArrayList();
alEmployee.add(Employee1);
alEmployee.add(Employee2);
alEmployee.add(Employee3);
alEmployee.add(Employee4);
alEmployee.add(Employee5);


int i=0;

for(Object o: alEmployee)
{
Employee objWordTestStatic =(Employee) o;

System.out.println(objWordTestStatic.sName);
objWordTestStatic.sName="sureshbabu"+i;

alEmployee.set(i, objWordTestStatic);
i++;



}

for(Object o: alEmployee)
{

System.out.println(((Employee)o).sName);


}

Re: Bookmark renaming

PostPosted: Wed Apr 11, 2012 1:35 pm
by jason
Find the bookmark starts via XPath or TraversalUtil (see Getting Started for details).

Then use CTBookmark's setName method.

@sureshbabubv, how is your reply relevant? Could you please explain or delete? thanks.

Re: Bookmark renaming

PostPosted: Wed Apr 11, 2012 9:10 pm
by Nanocom
Hi Jason, did what you suggested.
For the moment I rename the bookmarks in the main document and in the headers and footers.
Is there any other part where I can find bookmarks and where I should rename them ?
Thanks.

Re: Bookmark renaming

PostPosted: Wed Apr 11, 2012 9:41 pm
by sureshbabubv
Hi Jason,

If I am not mistaken, "Nanocom" is changed the text in his post, earlier he posted some code with the error he is getting.

where he found difficulty to convert an object to CTBookmarkname.

I tried to delete this post, but didn't found the delete link.

can you please delete it.

Thanks & Regards,
B.V.Suresh Babu.