Can someone explain how to convert VB code to Java with JACOB?

I am trying to create a document document from a template via JACOB / JAVA. I can't seem to find decent JACOB documentation. Can someone explain how Dispatch (.get | .put | .toDispatch) works? I am trying to convert the following code to JACOB:

   Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend
   Selection.Cells.Merge

I tried:

   Dispatch.call(oSelection, "MoveRight", 2, "Extend"); 
   Dispatch.call(oSelection, "Merge").toDispatch();

But it certainly does not work.

Any help would be appreciated.

+4
source share
1 answer

There is nothing wrong with Jacob; he works as advertised.

, Word 2003, , , , , . Selection.MoveRight. MoveRight: http://msdn.microsoft.com/en-us/library/aa212388 (v = office.11).aspx

expression.MoveRight(Unit, Count, Extend)

Unit Extend - , . wdCharacter - 1, wdExtend 1 ( , , VBA Office).

, oSelection , :

Dispatch.call(oSelection, "MoveRight", 1, 2, 1); 

. - :

Dispatch cells=Dispatch.get(oSelection,"Cells").toDispatch();//Selection.Cells.
Dispatch.call(cells, "Merge");                                       //Selection.Cells.Merge()

, toDispatch , Merge . toDispatch , , , Dispatch, .

+1

Source: https://habr.com/ru/post/1543213/


All Articles