<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="http://wiki.birth-online.de/lib/exe/css.php?s=feed" type="text/css"?>
<rss version="2.0">
    <channel>
        <title>mbirth's Wiki snippets:vba</title>
        <description></description>
        <link>http://wiki.birth-online.de/</link>
        <lastBuildDate>Fri, 10 Sep 2010 14:55:19 +0200</lastBuildDate>
        <generator>FeedCreator 1.7.2-ppt DokuWiki</generator>
        <image>
            <url>http://wiki.birth-online.de/lib/images/favicon.ico</url>
            <title>mbirth's Wiki</title>
            <link>http://wiki.birth-online.de/</link>
        </image>
        <item>
            <title>Update document properties</title>
            <link>http://wiki.birth-online.de/snippets/vba/docprop</link>
            <description>


&lt;h1&gt;&lt;a name=&quot;update-document-properties&quot; id=&quot;update-document-properties&quot;&gt;Update document properties&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;/div&gt;
&lt;!-- SECTION &quot;Update document properties&quot; [1-42] --&gt;
&lt;h2&gt;&lt;a name=&quot;find-and-write-parent-foldername&quot; id=&quot;find-and-write-parent-foldername&quot;&gt;Find and write parent foldername&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;
&lt;pre class=&quot;code vb&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; Document_Open()
  &lt;span class=&quot;co1&quot;&gt;'
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Kopfnamen-Makro
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Aktualisiert die Bezeichnung in der Kopfzeile anhand des Pfads
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Erstellt 12.11.2007 von Markus Birth &amp;lt;mbirth@webwriters.de&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;'
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' WICHTIG!!!!
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Im Ordner mit den Abteilungsbüchern muss eine Datei
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' .rootmarker.NichtLöschen.txt
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' existieren, damit die Bezeichnung richtig gesetzt wird
&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Set&lt;/span&gt; fs = CreateObject(&lt;span class=&quot;st0&quot;&gt;&amp;quot;Scripting.FileSystemObject&amp;quot;&lt;/span&gt;)
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; FN
  FN = ThisDocument.Name
  FP = ThisDocument.Path
  CRLF = Chr(13) &amp;amp; Chr(10)
&amp;nbsp;
  HBTIT = &lt;span class=&quot;st0&quot;&gt;&amp;quot;Evangelisches&amp;quot;&lt;/span&gt; &amp;amp; CRLF &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Waldkrankenhaus&amp;quot;&lt;/span&gt; &amp;amp; CRLF &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot;Spandau&amp;quot;&lt;/span&gt;
  RootM = &lt;span class=&quot;st0&quot;&gt;&amp;quot;.rootmarker.NichtLöschen.txt&amp;quot;&lt;/span&gt;
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
  BeautyName = Left(FN, Len(FN) - 4)
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;' Find Rootmarker
&lt;/span&gt;  IsFound = &lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;
  RMP = FP
  &lt;span class=&quot;kw1&quot;&gt;Do&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (fs.FileExists(RMP &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot;\&amp;quot;&lt;/span&gt; &amp;amp; RootM)) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
      IsFound = &lt;span class=&quot;kw1&quot;&gt;True&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
      pi = InStrRev(RMP, &lt;span class=&quot;st0&quot;&gt;&amp;quot;\&amp;quot;&lt;/span&gt;)
      &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (pi &amp;gt; 0) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; RMP = Left(RMP, pi - 1)
    &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Loop&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Until&lt;/span&gt; (IsFound &lt;span class=&quot;kw1&quot;&gt;Or&lt;/span&gt; pi = 0)
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (IsFound) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
    &lt;span class=&quot;co1&quot;&gt;' Root marker found in RMP, now find first folder
&lt;/span&gt;    FF = Mid(FP, Len(RMP) + 1)
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (Left(FF, 1) = &lt;span class=&quot;st0&quot;&gt;&amp;quot;\&amp;quot;&lt;/span&gt;) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; FF = Mid(FF, 2)
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (InStr(FF, &lt;span class=&quot;st0&quot;&gt;&amp;quot;\&amp;quot;&lt;/span&gt;) &amp;lt;&amp;gt; 0) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; FF = Left(FF, InStr(FF, &lt;span class=&quot;st0&quot;&gt;&amp;quot;\&amp;quot;&lt;/span&gt;) - 1)
&amp;nbsp;
    &lt;span class=&quot;co1&quot;&gt;' remove digits or spaces from beginning of text
&lt;/span&gt;    &lt;span class=&quot;kw1&quot;&gt;While&lt;/span&gt; (InStr(&lt;span class=&quot;st0&quot;&gt;&amp;quot;0123456789 .&amp;quot;&lt;/span&gt;, Left(FF, 1)) &amp;lt;&amp;gt; 0)
      FF = Mid(FF, 2)
    Wend
&amp;nbsp;
    AddProp &lt;span class=&quot;st0&quot;&gt;&amp;quot;AbtTitel&amp;quot;&lt;/span&gt;, FF &amp;amp; CRLF &amp;amp; HBTIT
  &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
    AddProp &lt;span class=&quot;st0&quot;&gt;&amp;quot;AbtTitel&amp;quot;&lt;/span&gt;, HBTIT
  &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; AddProp(PName, PVal)
  &lt;span class=&quot;co1&quot;&gt;' Fügt eine DokumentenVariable dem Dokument hinzu oder ändert eine bestehende
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Erstellt am 28.09.2005 von Markus Birth &amp;lt;mbirth@webwriters.de&amp;gt;
&lt;/span&gt;  num = 0
  &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Each&lt;/span&gt; e &lt;span class=&quot;kw1&quot;&gt;In&lt;/span&gt; ThisDocument.CustomDocumentProperties
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; e.Name = PName &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; num = 1
  &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; e
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; num = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
    ThisDocument.CustomDocumentProperties.Add PName, &lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;, msoPropertyTypeString, PVal
  &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
    ThisDocument.CustomDocumentProperties(PName).Value = PVal
  &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- SECTION &quot;Find and write parent foldername&quot; [43-1949] --&gt;
&lt;h2&gt;&lt;a name=&quot;split-parts-of-filename&quot; id=&quot;split-parts-of-filename&quot;&gt;Split parts of filename&lt;/a&gt;&lt;/h2&gt;
&lt;div class=&quot;level2&quot;&gt;
&lt;pre class=&quot;code vb&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; Document_Open()
  &lt;span class=&quot;co1&quot;&gt;'
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Kopfnamen-Makro
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Aktualisiert die Bezeichnung in der Kopfzeile anhand des Dateinamens
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Erstellt 28.09.2005 von Markus Birth &amp;lt;mbirth@webwriters.de&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;'
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' WICHTIG!!!!
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Das Dokument muss unter einem Verzeichnis &amp;quot;Band II&amp;quot; oder &amp;quot;PHB II&amp;quot; liegen,
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' damit das entsprechende PHB erkannt wird. Außerdem muss der Dateiname
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' folgende Richtlinien erfüllen:
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;'      &amp;lt;sortierung&amp;gt;_&amp;lt;kapitel&amp;gt; &amp;lt;Bezeichnung&amp;gt;_&amp;lt;Version&amp;gt;
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' z.B. 101_1.1 Pflege- und Versorgungskonzept_3.doc
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;'
&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; FN
  FN = ThisDocument.Name
  FP = ThisDocument.Path
&amp;nbsp;
  PHBNUM = &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;    &lt;span class=&quot;co1&quot;&gt;' &amp;quot;Band&amp;quot;
&lt;/span&gt;  PHBCHA = &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;    &lt;span class=&quot;co1&quot;&gt;' &amp;quot;Kapitel&amp;quot;
&lt;/span&gt;  PHBTIT = &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;    &lt;span class=&quot;co1&quot;&gt;' &amp;quot;Titel&amp;quot;
&lt;/span&gt;  PHBVER = 1     &lt;span class=&quot;co1&quot;&gt;' &amp;quot;Version&amp;quot;
&lt;/span&gt;  BeautyName = Left(FN, Len(FN) - 4)
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;' Find &amp;quot;Band&amp;quot; or &amp;quot;PHB&amp;quot; in path and read the word thereafter
&lt;/span&gt;  bi = InStr(1, FP, &lt;span class=&quot;st0&quot;&gt;&amp;quot;Band&amp;quot;&lt;/span&gt;, vbTextCompare)
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bi = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; bi = InStr(1, FP, &lt;span class=&quot;st0&quot;&gt;&amp;quot;PHB&amp;quot;&lt;/span&gt;, vbTextCompare)
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bi &amp;lt;&amp;gt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
    bi2 = InStr(bi, FP, &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;, vbTextCompare)
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bi2 = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; bi2 = InStr(bi + 1, FP, &lt;span class=&quot;st0&quot;&gt;&amp;quot;_&amp;quot;&lt;/span&gt;, vbTextCompare)
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bi2 &amp;lt;&amp;gt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
      bi3 = InStr(bi2 + 1, FP, &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;, vbTextCompare)
      &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bi3 = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; bi3 = InStr(bi2 + 1, FP, &lt;span class=&quot;st0&quot;&gt;&amp;quot;_&amp;quot;&lt;/span&gt;, vbTextCompare)
      &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; bi3 &amp;lt;&amp;gt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
        PHBNUM = &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; &amp;amp; Mid(FP, bi2 + 1, bi3 - bi2 - 1) &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot;:&amp;quot;&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;' Find chapter, chapter title and version
&lt;/span&gt;  ci = InStr(1, FN, &lt;span class=&quot;st0&quot;&gt;&amp;quot;_&amp;quot;&lt;/span&gt;, vbTextCompare)
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; ci &amp;lt;&amp;gt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
    ci2 = InStr(ci + 1, FN, &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt;, vbTextCompare)
    ci3 = InStr(ci + 1, FN, &lt;span class=&quot;st0&quot;&gt;&amp;quot;_&amp;quot;&lt;/span&gt;, vbTextCompare)
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; ci3 = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
      ci3 = InStr(ci + 1, FN, &lt;span class=&quot;st0&quot;&gt;&amp;quot;.doc&amp;quot;&lt;/span&gt;, vbTextCompare)
    &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
      ci4 = InStr(ci3 + 1, FN, &lt;span class=&quot;st0&quot;&gt;&amp;quot;.doc&amp;quot;&lt;/span&gt;, vbTextCompare)
      PHBVER = Mid(FN, ci3 + 1, ci4 - ci3 - 1)
    &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; ci2 &amp;lt;&amp;gt; 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
      PHBCHA = &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; &amp;amp; Mid(FN, ci + 1, ci2 - ci - 1)
      PHBTIT = Mid(FN, ci2 + 1, ci3 - ci2 - 1)
    &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
      PHBTIT = Mid(FN, ci + 1, ci3 - ci - 1)
    &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
    BeautyName = &lt;span class=&quot;st0&quot;&gt;&amp;quot;PHB&amp;quot;&lt;/span&gt; &amp;amp; PHBNUM &amp;amp; PHBCHA &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; &amp;amp; Chr(150) &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot; &amp;quot;&lt;/span&gt; &amp;amp; PHBTIT
  &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
&amp;nbsp;
  AddProp &lt;span class=&quot;st0&quot;&gt;&amp;quot;BeautyName&amp;quot;&lt;/span&gt;, BeautyName
  AddProp &lt;span class=&quot;st0&quot;&gt;&amp;quot;Version&amp;quot;&lt;/span&gt;, PHBVER
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;
&amp;nbsp;
&lt;span class=&quot;kw1&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; AddProp(PName, PVal)
  &lt;span class=&quot;co1&quot;&gt;' Fügt eine DokumentenVariable dem Dokument hinzu oder ändert eine bestehende
&lt;/span&gt;  &lt;span class=&quot;co1&quot;&gt;' Erstellt am 28.09.2005 von Markus Birth &amp;lt;mbirth@webwriters.de&amp;gt;
&lt;/span&gt;  num = 0
  &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Each&lt;/span&gt; e &lt;span class=&quot;kw1&quot;&gt;In&lt;/span&gt; ThisDocument.CustomDocumentProperties
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; e.Name = PName &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; num = 1
  &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; e
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; num = 0 &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
    ThisDocument.CustomDocumentProperties.Add PName, &lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;, msoPropertyTypeString, PVal
  &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
    ThisDocument.CustomDocumentProperties(PName).Value = PVal
  &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;!-- SECTION &quot;Split parts of filename&quot; [1950-] --&gt;</description>
        <category>snippets:vba</category>
            <pubDate>Tue, 15 Jul 2008 23:23:06 +0200</pubDate>
        </item>
        <item>
            <title>Select ListBox entries</title>
            <link>http://wiki.birth-online.de/snippets/vba/select-listbox-entries</link>
            <description>


&lt;h1&gt;&lt;a name=&quot;select-listbox-entries&quot; id=&quot;select-listbox-entries&quot;&gt;Select ListBox entries&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

Takes a comma-separated list and selects matching entries of a ListBox.
&lt;/p&gt;
&lt;pre class=&quot;code vb&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; MarkMe(List &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; ListBox, Items &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; TextBox)
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; MergedData &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; iArray &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (&lt;span class=&quot;kw1&quot;&gt;Not&lt;/span&gt; IsNull(Items.Value)) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; MergedData = Items.Value
&amp;nbsp;
  iArray = Split(MergedData, &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;, -1, vbTextCompare)
&amp;nbsp;
  &lt;span class=&quot;co1&quot;&gt;' set everything to false (deselect all)
&lt;/span&gt;  &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; intI = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; List.ListCount
    List.Selected(intI) = &lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; intI
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Each&lt;/span&gt; curItem &lt;span class=&quot;kw1&quot;&gt;In&lt;/span&gt; iArray
    curItem = Trim(curItem)
    &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; intI = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; List.ListCount
      &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; List.ItemData(intI) = curItem &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
        List.Selected(intI) = &lt;span class=&quot;kw1&quot;&gt;True&lt;/span&gt;
        &lt;span class=&quot;kw1&quot;&gt;Exit&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; intI
  &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; curItem
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
</description>
        <category>snippets:vba</category>
            <pubDate>Tue, 15 Jul 2008 23:20:31 +0200</pubDate>
        </item>
        <item>
            <title>VBA</title>
            <link>http://wiki.birth-online.de/snippets/vba/start</link>
            <description>


&lt;h1&gt;&lt;a name=&quot;vba&quot; id=&quot;vba&quot;&gt;VBA&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

VisualBasic for Applications.
&lt;/p&gt;
&lt;script type='text/javascript' charset='utf-8'&gt;
&lt;!--//--&gt;&lt;![CDATA[//&gt;&lt;!--
indexmenu_nojsqueue.push(new Array('indexmenu_6782098834c8a2ab772b77',''));
addInitEvent(function(){indexmenu_loadJs(DOKU_BASE+'lib/plugins/indexmenu/nojsindex.js');});
//--&gt;&lt;!]]&gt;
&lt;/script&gt;

&lt;div id=&quot;nojs_indexmenu_6782098834c8a2ab772b77&quot; class=&quot;indexmenu_nojs&quot;&gt;

&lt;ul class=&quot;idx&quot;&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a href=&quot;http://wiki.birth-online.de/snippets/vba/docprop&quot; class=&quot;wikilink1&quot; title=&quot;snippets:vba:docprop&quot;&gt;Update document properties&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a href=&quot;http://wiki.birth-online.de/snippets/vba/select-listbox-entries&quot; class=&quot;wikilink1&quot; title=&quot;snippets:vba:select-listbox-entries&quot;&gt;Select ListBox entries&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li class=&quot;level1&quot;&gt;&lt;div class=&quot;li&quot;&gt;&lt;a href=&quot;http://wiki.birth-online.de/snippets/vba/update-listbox-from-csv&quot; class=&quot;wikilink1&quot; title=&quot;snippets:vba:update-listbox-from-csv&quot;&gt;Update ListBox from comma-separated text&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;/div&gt;

&lt;/div&gt;
</description>
        <category>snippets:vba</category>
            <pubDate>Tue, 15 Jul 2008 23:18:18 +0200</pubDate>
        </item>
        <item>
            <title>Update ListBox from comma-separated text</title>
            <link>http://wiki.birth-online.de/snippets/vba/update-listbox-from-csv</link>
            <description>


&lt;h1&gt;&lt;a name=&quot;update-listbox-from-comma-separated-text&quot; id=&quot;update-listbox-from-comma-separated-text&quot;&gt;Update ListBox from comma-separated text&lt;/a&gt;&lt;/h1&gt;
&lt;div class=&quot;level1&quot;&gt;

&lt;p&gt;

Updates a comma-separated text in a TextBox, adding newly selected values in a ListBox or removing deselected ones, leaving everything not in the ListBox untouched.
&lt;/p&gt;
&lt;pre class=&quot;code vb&quot;&gt;&lt;span class=&quot;kw1&quot;&gt;Private&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt; UpdateMe(List &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; ListBox, Items &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; TextBox)
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; MergedData &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;String&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; iArray &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; nArray &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Variant&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Dim&lt;/span&gt; Found &lt;span class=&quot;kw1&quot;&gt;As&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Boolean&lt;/span&gt;
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; (&lt;span class=&quot;kw1&quot;&gt;Not&lt;/span&gt; IsNull(Items.Value)) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
    MergedData = Items.Value
    iArray = Split(MergedData, &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;, -1, vbTextCompare)
  &lt;span class=&quot;kw1&quot;&gt;Else&lt;/span&gt;
    iArray = Array()
  &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
  nArray = Array(&lt;span class=&quot;st0&quot;&gt;&amp;quot;PRE&amp;quot;&lt;/span&gt;)
&amp;nbsp;
  &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; intI = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; List.ListCount
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; List.Selected(intI) &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
      nArray = Split(Join(nArray, &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;) &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt; &amp;amp; List.ItemData(intI), &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;, -1, vbTextCompare)
    &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
  &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; intI
  &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Each&lt;/span&gt; curItem &lt;span class=&quot;kw1&quot;&gt;In&lt;/span&gt; iArray
    curItem = Trim(curItem)
    Found = &lt;span class=&quot;kw1&quot;&gt;False&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;For&lt;/span&gt; intI = 0 &lt;span class=&quot;kw1&quot;&gt;To&lt;/span&gt; List.ListCount
      &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; List.ItemData(intI) = curItem &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt;
        Found = &lt;span class=&quot;kw1&quot;&gt;True&lt;/span&gt;
      &lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt;
    &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; intI
    &lt;span class=&quot;kw1&quot;&gt;If&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Not&lt;/span&gt; Found &lt;span class=&quot;kw1&quot;&gt;Then&lt;/span&gt; nArray = Split(Join(nArray, &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;) &amp;amp; &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt; &amp;amp; curItem, &lt;span class=&quot;st0&quot;&gt;&amp;quot;,&amp;quot;&lt;/span&gt;, -1, vbTextCompare)
  &lt;span class=&quot;kw1&quot;&gt;Next&lt;/span&gt; curItem
&amp;nbsp;
  MergedData = Join(nArray, &lt;span class=&quot;st0&quot;&gt;&amp;quot;, &amp;quot;&lt;/span&gt;)
  MergedData = Replace(MergedData, &lt;span class=&quot;st0&quot;&gt;&amp;quot;PRE, &amp;quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;)
  MergedData = Replace(MergedData, &lt;span class=&quot;st0&quot;&gt;&amp;quot;PRE&amp;quot;&lt;/span&gt;, &lt;span class=&quot;st0&quot;&gt;&amp;quot;&amp;quot;&lt;/span&gt;)
  Items.Value = MergedData
&lt;span class=&quot;kw1&quot;&gt;End&lt;/span&gt; &lt;span class=&quot;kw1&quot;&gt;Sub&lt;/span&gt;&lt;/pre&gt;

&lt;/div&gt;
</description>
        <category>snippets:vba</category>
            <pubDate>Tue, 15 Jul 2008 23:19:51 +0200</pubDate>
        </item>
    </channel>
</rss>
