<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Vb function included using ExecuteGlobal not working in load-script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732780#M452417</link>
    <description>&lt;P&gt;Bingo !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you a lot Cwolf.&lt;/P&gt;</description>
    <pubDate>Mon, 03 Aug 2020 12:47:24 GMT</pubDate>
    <dc:creator>G_Zeni</dc:creator>
    <dc:date>2020-08-03T12:47:24Z</dc:date>
    <item>
      <title>Vb function included using ExecuteGlobal not working in load-script</title>
      <link>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732424#M452394</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;Before writing this message I spent a lot of time (without success) to read blogs in order to find a solution.&lt;/P&gt;&lt;P&gt;The goal is simpy: I want to share and reuse vb code as function in &lt;STRONG&gt;load-script&lt;/STRONG&gt;&amp;nbsp;between different QlikView applications.&lt;/P&gt;&lt;P&gt;The way I tried to di it is to put vb code into a file and load it using vb &lt;STRONG&gt;ExecuteGlobal&lt;/STRONG&gt; statement.&lt;/P&gt;&lt;P&gt;For test I did as follow:&lt;BR /&gt;1) I created a file named "vbCode.vb" with this simply content:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#000080"&gt;&lt;EM&gt;function f_externalSum(p_val1, p_val2)&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;EM&gt;f_externalSum = p_val1 + p_val2&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#000080"&gt;&lt;EM&gt;end function&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;2) In macro editor I succesfully loaded vb code from "vbCode.vb" file using "ExecuteGlobal" as described in many posts and I noticed that vb functions code name (&lt;STRONG&gt;f_externalSum&lt;/STRONG&gt;) is correctly load inside macro editor.&lt;/P&gt;&lt;P&gt;3) In script editor (not macro editor) I wrote this code:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;FONT color="#000080"&gt;&lt;EM&gt;let totalExternal = f_externalSum(5, 2);&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;The editor did not show any syntax error (it recognized the f_externalSum function)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The problem: &lt;STRONG&gt;when I run the load script I receive "syntax error".&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Macro code:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;call Include()&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;sub Include()&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;Dim v_vbCodeFile, o_fso, o_file, v_vbCode&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;v_vbCodeFile = ".\vbCode.vb"&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;Set o_fso = CreateObject("Scripting.FileSystemObject")&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;set o_file = o_fso.OpenTextFile(ActiveDocument.GetProperties.MyWorkingDirectory &amp;amp; "\" &amp;amp;v_vbCodeFile)&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;v_vbCode = o_file.ReadAll&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;o_file.Close&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;ExecuteGlobal v_vbCode&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#000080"&gt;end sub&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 11:53:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732424#M452394</guid>
      <dc:creator>G_Zeni</dc:creator>
      <dc:date>2020-07-31T11:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: Vb function included using ExecuteGlobal not working in load-script</title>
      <link>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732769#M452416</link>
      <description>&lt;P&gt;If you call a macro from script, you have no access to the "ActiveDocument" object or to the "Application" object. Thatswhy you have to use a absolute path to external scripts in macro.&lt;/P&gt;&lt;P&gt;Normally, you will have a global share for external scripts (qvs and vb), for example "\\server\scripts\":&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;call Include()

sub Include()
    v_vbCodeFile = "\\server\scripts\vbCode.vb"
    Set fso = CreateObject("Scripting.FileSystemObject")
    ExecuteGlobal fso.OpenTextFile(v_vbCodeFile).ReadAll
end sub&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 03 Aug 2020 12:00:21 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732769#M452416</guid>
      <dc:creator>cwolf</dc:creator>
      <dc:date>2020-08-03T12:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Vb function included using ExecuteGlobal not working in load-script</title>
      <link>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732780#M452417</link>
      <description>&lt;P&gt;Bingo !!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you a lot Cwolf.&lt;/P&gt;</description>
      <pubDate>Mon, 03 Aug 2020 12:47:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Vb-function-included-using-ExecuteGlobal-not-working-in-load/m-p/1732780#M452417</guid>
      <dc:creator>G_Zeni</dc:creator>
      <dc:date>2020-08-03T12:47:24Z</dc:date>
    </item>
  </channel>
</rss>

