Four Js Development Tools Forum

Discussions by product => Genero BDL => Topic started by: Stefan S. on June 12, 2009, 09:21:44 am



Title: wincom and Word
Post by: Stefan S. on June 12, 2009, 09:21:44 am
Hello List,

Documents.Open FileName:="z:\brief.doc"
the line above is a part of a VB-Makro in Word (it works!)

how can I write this line in Genero-syntax ?

I trieyd several versions
f.e.:
  CALL ui.interface.frontCall("WinCOM", "CallMethod",
                              [wwapp, 'Documents.Open FileName("z:\brief.doc")'], [wwdoc])

But I always get this 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.
Exit with COM Error.


open an empty document works fine
CALL ui.interface.frontCall("WinCOM", "CallMethod", [wwapp, "Documents.Add"], [wwdoc])

I think it has to do with parameters for the method I am calling, but what is the correct syntax ?

thanks 

Stefan



Title: Re: wincom and Word
Post by: Paul S. on June 12, 2009, 09:55:29 am
Hi Stefan,

try

CALL ui.Interface.frontCall("WINCOM","CallMethod", [wlapp,"Documents.Open",l_f],[wdoc])

where l_f is a STRING containing the file name

Paul


Title: Re: wincom and Word
Post by: Stefan S. on June 12, 2009, 11:39:54 am
Thanks Paul,

it works like you wrote:
  let str = 'z:\brief.doc'
  CALL ui.interface.frontCall("WinCOM", "CallMethod", [wwapp, "Documents.Open", str], [wwdoc])

but the Method "Documents.Open" has more Parameter. A complete VBA-Statement looks
is f.e.:
    ChangeFileOpenDirectory "Z:\"
    Documents.Open FileName:="brief.doc", ConfirmConversions:=False, ReadOnly _
        :=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate _
        :="", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="" _
        , Format:=wdOpenFormatAuto

How can I submit other Parameters to Word ??

The same Problem I have with the "goto" Statement
Goto a LineNumber  8 in VBA:     Selection.GoTo What:=wdGoToLine, Which:=wdGoToFirst, Count:=8, Name:=""
Goto a BookMark plz_ort:       Selection.GoTo What:=wdGoToBookmark, Name:="plz_ort"


Thanks Stefan



Title: Re: wincom and Word
Post by: Paul S. on June 12, 2009, 12:00:37 pm
Hi Stefan,

to be honest its a little hit and miss at times. I (and a few others) have spent hours looking at what VB does to connect to Word/Excel extra. There are loads of examples on the Internet (just use google), also MS has on-line documents to example most of the methods for MS-Office.

I have attached the lib. module we use to Word, most of it works, some I give up on (no time to finish).

For bookmarks I do:

FUNCTION word_com_bookmark(l_find)
DEFINE res,lin     INTEGER
DEFINE l_find      STRING  -- BookMark
DEFINE l_arg      STRING

   LET m_para = l_find.trim()
   LET l_arg = "ActiveDocument.Bookmarks(",g_quote.trim(),l_find.trim(),g_quote.trim(),").Select"
   CALL ui.Interface.frontCall("WINCOM","CallMethod",[wlapp,l_arg.trim()],[res])
   IF word_com_error(1,res, __LINE__) THEN
      RETURN FALSE
   END IF

   RETURN TRUE
END FUNCTION

Paul


Title: Re: wincom and Word
Post by: . on June 12, 2009, 12:30:25 pm
Without having tried, I would suggest to use the () notation for function calls:

Document.Open(foo, bar)

instead of

Document.Open foo bar

VBScript is, as the name state, a complete scripting language ; GDC WinCOM API is just a bridge between 4GL and the pure WIN32 COM API, so basically we have our own script parser which is not as extented as the one from Microsoft (if anyone knows how to integrate the one from Ms in C++ application...)

So this is one of the major limitation of WinCOM API: the parser could be smarted, but we're running out of time to improve it.
The other one is data type limitation: frontCalls are only based on INTEGER / STRINGs, so we've made some internal tricks to support handles, but this works only in a strict and defined context.

So - again, without having tested, sorry - I would use:

  CALL ui.interface.frontCall("WinCOM", "CallMethod",
                              [wwapp, 'Documents.Open("z:\brief.doc")'], [wwdoc])

The := notation is supported, but not mandatory.

HIH,
regards,
Pierre-Nicolas


Title: Re: wincom and Word
Post by: Stefan S. on June 12, 2009, 12:45:59 pm
Thanks Paul,
I will have a deeper look to your word_com lib. I think there are many intresting statements.
I even spent a lot of time with searching for the correct syntax, but without much success.
Do you have some links (Excel an Word)



Stefan


Title: Re: wincom and Word
Post by: Paul S. on June 12, 2009, 12:55:16 pm
Hi Stefan,

some links I have used are:

http://www.neng.usu.edu/cee/faculty/gurro/VBA&Excel.htm
http://msdn.microsoft.com/en-us/library/bb726434.aspx
http://msdn.microsoft.com/en-us/library/bb190882(office.11).aspx

This last one was a helps with a problem if the application aborts or does not close.

http://www.tushar-mehta.com/excel/vba/xl_doesnt_quit/

For Excel I have limited myself to using the clipboard to copy and paste from an array, there are already a few examples of this on the board.

Paul


Title: Re: wincom and Word Excel
Post by: Paul S. on June 12, 2009, 01:01:05 pm
Hi Stefan,

my excel.4gl lib. function.

most of it is copied from what other people have posted in the past.

Paul