Solved

Document Macros



Show first post

27 replies

Userlevel 2
Badge +6

@NMALKI 

Hi,
Regarding adding data from IFS into an Excel document there is a good base example in the Online Documentation (F1) reached from Basic Data/Macros Basic that you can build upon. In my example I will assume the Excel Application object (oXl) has been created according to that base example. I will also assume the rest of the supporting code is known and used.

In the Online Documentation, the example shows how to use row and column indexes together with the Cells() method. But to relate to your question about using something similar to Quick Parts/Fields in Microsoft Word I will use the Range() method instead in my example.

To set up the similar part to a Fields [MS Word] you should use the Name Manager (under Formulas) in Excel for your template. There you define Names for each cell you want to address. (I will not go into things like Scope, i.e. context validity of the Name between sheets and workbook here.)

Example:
Public Sub Test()

    Open_Excel

    Write_To_Range "MyRange", "DOC_NO"

End Sub

 

Public Sub Write_To_Range(range, attr)

    attrValue = ScriptValues.Item(UCase(attr)).Value

    oXl.range("MyRange") = attrValue

End Sub

 

Regarding inserting an SQL or function in the macro it would as Mathias mentioned be more of a development effort but very shorty it could be achieved by using the framework provided by IFS .Net Access Provider (IFSAP). Here you must of course take into consideration things like which version you work with and how to handle security and login aspects. Looking towards IFS Cloud you might also have to consider if REST API or more specifically oData should be a part of your future strategy. I have only worked with IFSAP yet in this context though.
At the same time, you may be able to achieve what you want with your SQL or function by implementation it via a Custom Field (which can be fetch from a connected object) or via a (unused) metadata field that is available as a standard document attribute to the macro (see F1 Help for available attributes). The value (i.e. the result of the SQL or function) could be inserted/updated via a Custom Event in the standard metadata field.

 

Hope this was to a little help anyway,

Erik

Userlevel 5
Badge +10

@xeam-eran you are amazing :) thanks so much for your help. That's what I really need ...much appreciate

Reply