Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Word Wincom Help  (Read 14852 times)
Paul S.
Posts: 45


« on: May 21, 2008, 06:20:57 pm »


FrontEnd: Xp (SP2) , GDC 2.02.09-352.212
BackEnd: Redhat 4, Genero 2.02.02-966.12

Trying to use the GoTo method in Word 2003 to move to a new position in
a document.

1. Open a Word 2003 Template which has a Bookmark called Start

2. Run following:

    CALL ui.Interface.frontCall("WINCOM","CallMethod",
        [wlapp,"Selection.GoTo",'What:=wdGoToBookmark, Name:="Start"'],[res])
    IF word_com_error(res, __LINE__) THEN
        RETURN FALSE
    END IF

I have changed the argument list a few times, split it up "What","Name" ,
single argument etc..

Everytime I run this line I get a Bad Parameter error.

I can open the template and save with a new name no problem, I can paste data into
the word document, but cannot position the cursor to the bookmark.

I can open the template (not using wincom) and use the Edit/GoTo option to move to the
bookmark, I have recorded a macro and the macro looks just like the method above.

I have followed this link from the MSDN web site
http://msdn.microsoft.com/en-us/library/aa172261(office.11).aspx

And I appear to be doing the call right.

Any ideas?

Thanks

Paul
Lionel F.
Four Js
Posts: 83


« Reply #1 on: June 04, 2008, 05:52:41 pm »

Hello,

In your case, the problem comes probably from on a known limitation of the Wincom syntax :
- "no parenthesis" notation is not allowed ; for instance:  myFunction 3 must be written  myFunction(3)
(https://4js.com/online_documentation/fjs-gdc-2.11.01-manual-html/User/WinCOM.html)

In your example, in VBA, the syntax should be :
Code
  1. Selection.GoTo What:=WdGoToBookmark, Name:="Start"

There is a blank space between "GoTo" and "What", therefore, this syntax is not adaptable to the Wincom API.

Maybe you could try the following one :
Code
  1. Selection.GoTo (WdGoToBookmark,"","","Start")

It might work but it could also depend on the Word version which is used (on my side, it didn't work with 2002-SP1)

Don't hesitate to get back to me if you need further information.

Best regards,
Lionel   
Paul S.
Posts: 45


« Reply #2 on: June 04, 2008, 07:02:43 pm »

Hi Thanks for the reply, I have messed around a little and these are the results.

I got round the problem by using:

   [wlapp,'ActiveDocument.Bookmarks("bkStart").Select'],[res])

What I am finding hard to understand/confusing is the relationship between the CallMethod options and
the VBA commands used by MS.

For example MS states the GoTo Method as: expression.GoTo(What, Which, Count, Name)

WinCom as: CALL ui.Interface.frontCall("WINCOM","CallMethod",[ handle, method, arg1, ... ], [result] )

Which I assume means:-

method is the member name to call = expression.GoTo
arg1,... is the arguments = What,Which,Count,Name

should we be passing the arguments within parenthesis "()" as part of the method "GoTo(arg1,arg2)
or as a single argument (arg1,arg2...) or a list of arguments (arg1),(arg2).

If the arguments are part of the method , can the arg1 option be left out?

At the end of the day I got a solution and I accept that the problem could be MS
(plenty of examples on the Internet show what MS says does not always work)

Thanks again.

The attempts below give me errors?

1.     [wlapp,'Selection.GoTo (What:=wdGoToBookmark, Name:="bkStart")'],[res])
Error: "One or more of the names were not known. The returned array of DISPIDs
     contains DISPID_UNKNOWN for each entry that corresponds to an unknown name."

2.     [wlapp,'Selection.GoTo(What:=wdGoToBookmark,Name:="bkStart")'],[res])
Error: "One of the arguments in rgvarg is not a valid variant type."

3.    [wlapp,'Selection.GoTo(What:=wdGoToBookmark,Name:="bkStart")',""],[res])
Error: Bad Parameter.

4.     [wlapp,'Selection.GoTo','(wdGoToBookmark,"","","bkStart")'],[res])
Error: Bad Parameter

5.     [wlapp,'ActiveDocument.GoTo(What:=wdGoToBookmark,"","",Name:="bkStart")'],[res])
Error: One of the arguments in rgvarg is not a valid variant type.

6.     [wlapp,'ActiveDocument.GoTo(wdGoToBookmark,"","","bkStart")'],[res])
Error: ne of the arguments in rgvarg is not a valid variant type.
Lionel F.
Four Js
Posts: 83


« Reply #3 on: June 10, 2008, 02:44:17 pm »

Hi Paul,

Well-judged! Your syntax is indeed working...

I did not find any way to make work this using the method GoTo ().

Now, you're right, I admit that the Wincom documentation is not pretty clear regarding the relationship between the CallMethod options and the VBA commands used by MS.

This is probably a thing we have to explain more deeply with further concrete examples. Anyway, the goal is, eventually, to improve the whole documentation concerning Wincom.

Thank you again for posting,
Best regards
Paul S.
Posts: 45


« Reply #4 on: June 10, 2008, 02:57:06 pm »

Hi Lionel , thanks for the reply.

I look forward to seeing any new documentation on how to use Wincom, in the mean time I will use Google to check if the VBA methods work as per the MSDN website, this is how a got the solution in the end.

Paul
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines