Can someone explain how to convert VB code to Java using Jacob?

I am trying to create a word document from a template via JACOB/JAVA. I can’t seem to find any decent document on JACOB. Can someone explain how Dispatch works (.get | .put | .toDispatch)? I want 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 definitely doesn’t work.

Any help will be greatly appreciated.

Jacob has no problems, it works the same way as advertising.

First of all, you The object reference of Word 2003 must be found, you seem to be using it
The reason is that when using named parameters, some optional parameters can be omitted, and some parameters can be specified out of order. So I first need to confirm Selection.MoveRight The following is MoveRight: http://msdn.microsoft.com/en-us/library/aa212388(v=office.11).aspx’s document

expression .MoveRight(Unit, Count, Extend)

Unit and Extend are enumerations, so we must find the correct integer constants for them. wdCharacter is 1, and wdExtend is also 1 (how do you come up with these values Different, the easiest way is to look at the Object Browser in the VBA editor of the Office application).

Assuming oSelection is a valid object, this should work:

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

Now for the second row, you forgot the cell in the translation. You need something like this:

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

Please note that I ToDatch will not be called on the second line, because Merge will not return anything. toDispatch is used to convert the return value (such as the first line) into a Dispatch object, which I can call later on.

I am trying to create a word document from a template via JACOB/JAVA. I can’t seem to find any decent document on JACOB. Can someone explain how Dispatch works (.get | .put | .toDispatch)? I want 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 definitely doesn’t work.

Any help will be greatly appreciated.

Jacob doesn’t have any problems, it works the same as the advertisement.

First, you have to find the object reference of Word 2003, you seem to be using It
the reason is that when using named parameters, some optional parameters can be omitted, and some parameters can be specified out of order. So I first need to confirm the signature of Selection.MoveRight. The following is MoveRight: http://msdn .microsoft.com/en-us/library/aa212388(v=office.11).aspx’s documentation

expression.MoveRight(Unit, Count, Extend)

Unit and Extend are enumerations, so we must find the correct integer constants for them. wdCharacter is 1, and wdExtend is also 1 (how do you figure out the difference in these values, the easiest way is to look at the Office application Object browser in the VBA editor).

Assuming oSelection is a valid object, this should work:

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

Now for the second row, you forgot the cell in the translation. You need something like this:

< pre>Dispatch cells=Dispatch.get(oSelection,”Cells”).toDispatch();//Selection.Cells.
Dispatch.call(cells, “M erge”); //Selection.Cells.Merge()

Please note that I will not call toDatch on the second line because Merge will not return anything. toDispatch is used to return the return value (such as the first One line) is converted to a Dispatch object, and I can use this object to call the object later.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 3455 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.