<?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 Include external module/macro code in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146513#M505136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob, thanks for your idea! I was able to get your code working with some slight changes. The working directory needs to be included in the code file. So you need to replace this line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with these 4 lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set mypath = ActiveDocument.GetProperties&lt;BR /&gt;directory = mypath.MyWorkingDirectory &lt;BR /&gt;codefile = directory &amp;amp; "\commonFunctions.vbs"&lt;BR /&gt;Set file = objFSO.OpenTextFile(codefile)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The only problem now is that the code is not password protected. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions on hiding this code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried saving the QVW after I loaded the external code, but when I reopened it, the external code had not been saved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I could also encrypt the VBS files manually, but that's not ideal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Nov 2011 00:31:45 GMT</pubDate>
    <dc:creator />
    <dc:date>2011-11-09T00:31:45Z</dc:date>
    <item>
      <title>Include external module/macro code</title>
      <link>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146511#M505134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;there is the possibility to export the macro-/module-code ...&lt;BR /&gt;&lt;BR /&gt;Is there a similar possibility to import/include "external" macro-code with a statement like the include-statement within loading-scripts?&lt;BR /&gt;&lt;BR /&gt;I would need this functionality to organize some code within in project with many modules/subs ...&lt;BR /&gt;&lt;BR /&gt;Thanks in advance &amp;amp; best regards&lt;/P&gt;&lt;P&gt;Stefan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2009 03:58:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146511#M505134</guid>
      <dc:creator />
      <dc:date>2009-06-11T03:58:11Z</dc:date>
    </item>
    <item>
      <title>Include external module/macro code</title>
      <link>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146512#M505135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stefan, Here's one way to do it.&lt;/P&gt;&lt;P&gt;1. Put your common code in a file, say "commonFunctions.vbs".&lt;/P&gt;&lt;P&gt;2. Add this macro code to your Qlikview Document module:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;Call IncludeCommon&lt;BR /&gt;Sub IncludeCommon&lt;BR /&gt; Dim objFSO, file, str&lt;BR /&gt; Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;BR /&gt; Set file = objFSO.OpenTextFile("commonFunctions.vbs")&lt;BR /&gt; str = file.ReadAll&lt;BR /&gt; file.Close&lt;BR /&gt; ExecuteGlobal str&lt;BR /&gt;End Sub&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;Press the "Check" button. Bingo, your externally defined Functions and Subs are available. Your document must be granted system access for this to work.&lt;/P&gt;&lt;P&gt;Changes made to the external file will be picked up each time the document is opened. If you are developing and don't want to open/close the doc, making an edit change to the document module will pick up the changes as well.&lt;/P&gt;&lt;P&gt;Let me know if this works for you. I haven't actually tried this in production.&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2009 08:48:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146512#M505135</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2009-06-11T08:48:13Z</dc:date>
    </item>
    <item>
      <title>Include external module/macro code</title>
      <link>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146513#M505136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rob, thanks for your idea! I was able to get your code working with some slight changes. The working directory needs to be included in the code file. So you need to replace this line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set objFSO = CreateObject("Scripting.FileSystemObject")&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;with these 4 lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;set mypath = ActiveDocument.GetProperties&lt;BR /&gt;directory = mypath.MyWorkingDirectory &lt;BR /&gt;codefile = directory &amp;amp; "\commonFunctions.vbs"&lt;BR /&gt;Set file = objFSO.OpenTextFile(codefile)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The only problem now is that the code is not password protected. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone have any suggestions on hiding this code?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried saving the QVW after I loaded the external code, but when I reopened it, the external code had not been saved.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I guess I could also encrypt the VBS files manually, but that's not ideal.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 00:31:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146513#M505136</guid>
      <dc:creator />
      <dc:date>2011-11-09T00:31:45Z</dc:date>
    </item>
    <item>
      <title>Include external module/macro code</title>
      <link>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146514#M505137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;One method could be to create a Master .qvw containing the macros and password protect it, then use code in the destination document to read the master code and overwrite it.&amp;nbsp; I have managed to do this as follows (all documents in same folder to simplify) ...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create ModuleMaster.qvw and password protect.&amp;nbsp; Module needs to include the import .vbs routine as above.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Create .vbs file with following code ...&lt;/P&gt;&lt;P&gt;Function GetScript(Doc)&lt;BR /&gt; set QV=CreateObject("QlikTech.QlikView")&lt;BR /&gt; set Doc&amp;nbsp; = QV.OpenDoc (Doc)&lt;BR /&gt; set props = Doc.GetProperties&lt;BR /&gt; GetScript = props.VBModule&lt;BR /&gt; Doc.CloseDoc&lt;BR /&gt;End Function&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sub ModifyScript&lt;BR /&gt; set docprop = ActiveDocument.GetProperties&lt;BR /&gt; docprop.VBModule = GetScript("ModuleMaster.qvw")&lt;BR /&gt; ActiveDocument.SetProperties docprop&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In destination document, include just the import .vbs routine again, click check and the ModifyScript sub should be available.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;4)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Run the ModifyScript (enter ModuleMaster.qvw credentials if needed) and the script should be overwritten.&amp;nbsp; As we have included the import .vbs routine in ModuleMaster, it is retained for future use.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A word of warning though, I did observe that on one test my module wouldn't display the subs after "Check"-ing and I had to close and restart QV, but hopefully this could give some ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;flipside&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Nov 2011 10:48:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Include-external-module-macro-code/m-p/146514#M505137</guid>
      <dc:creator>flipside</dc:creator>
      <dc:date>2011-11-09T10:48:56Z</dc:date>
    </item>
  </channel>
</rss>

