<?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 EG: Task skipped, looping over Items in process flow (VBA SASEGObjectModel) in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Task-skipped-looping-over-Items-in-process-flow-VBA/m-p/623088#M35500</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this code, when I loop through objects in a process flow, I find that certain objects, specifically tasks, are skipped.&amp;nbsp; In this recent instance (I have not provided the EGP file)&amp;nbsp; the code below opened and recognized all the other objects and created a message box output ("Unsorted&amp;lt;--"...) relaying their name, but not so for the "Summary Tables" task.&amp;nbsp; Another version of the code outputs the code of program nodes and query builder objects, successfully; I would also like to access &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;code &lt;/SPAN&gt;connected to tasks as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because I'm not getting a "item.Name" or an&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;"item.Type"&lt;/SPAN&gt; from the task, does that mean the task is not in the process flow container?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And its hard to search for this type of question, forgive me if its repeated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code is run using Excel VBA; Code is based on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; 's code, published &lt;A href="https://github.com/cjdinger/sas-eg-automation/blob/master/vbscript/ExtractCode.vbs" target="_self"&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Option Explicit
Dim Application ' As SASEGuide.Application

Sub EGPConvert_v8()
  Dim Project
  
  ' Change if running a different version of EG
  Dim egVersion
  egVersion = "SASEGObjectModel.Application.8.1"
  
  Dim item
  Dim flow
  Dim Unsorted
  Dim Items_Sorted
  Dim outputFilename As String
  Dim i As Integer
  Dim EGPfile As String
  Dim programsFolder As String
  Dim objFS 'As "Scripting.FileSystemObject"
  Dim objOutFile ' As TextStream
&lt;BR /&gt;  '******************************************************** &lt;BR /&gt;  ' Get...&lt;BR /&gt;  EGPfile = Interface.Get_FileName() 'File name and path
  programsFolder = Interface.Get_Destination() 'Folder path
    
  '********************************************************
  ' Create a new SAS Enterprise Guide automation session
  On Error Resume Next
  Set Application = CreateObject(egVersion)
  If Err.Number &amp;lt;&amp;gt; 0 Then
    MsgBox "ERROR: Need help with 'Set Application = CreateObject(egVersion)"
    End
  End If
   MsgBox Application.Name &amp;amp; ", Version: " &amp;amp; Application.Version &amp;amp; vbCrLf &amp;amp; "Opening project: " &amp;amp; EGPfile
  
  '********************************************************
  ' Open the EGP file with the Application
  Set Project = Application.Open(EGPfile, "")
  If Err.Number &amp;lt;&amp;gt; 0 Then
    MsgBox "ERROR: Unable to open " &amp;amp; EGPfile &amp;amp; " as a project file"
      End
  End If
  
  '********************************************************
  'Open the output file
  MkDir programsFolder &amp;amp; Project.Name
  outputFilename = programsFolder &amp;amp; Project.Name &amp;amp; "\" &amp;amp; Project.Name &amp;amp; ".sas"
  'MsgBox "saving code to " &amp;amp; vbCrLf &amp;amp; outputFilename
  
  Set objFS = CreateObject("Scripting.FileSystemObject")
  Set objOutFile = objFS.CreateTextFile(outputFilename, True)
  
  '********************************************************
  'Prepare the unsorted list
  Set Unsorted = CreateObject("System.Collections.ArrayList")
  
  '********************************************************
  ' Navigate the process flows in the Project object
  For Each flow In Project.ContainerCollection
    ' ProcessFlow is ContainerType of 0
    If flow.ContainerType = 0 Then
        'MsgBox "Process Flow: " &amp;amp; flow.Name
    ' Navigate the items in each process flow
    For Each item In flow.Items
      MsgBox "=Unsorted&amp;lt;--" &amp;amp; item.Name &amp;amp; " Type: " &amp;amp; item.Type
      Unsorted.Add item
    Next
    End If
  Next&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2020 15:53:49 GMT</pubDate>
    <dc:creator>PhilC</dc:creator>
    <dc:date>2020-02-07T15:53:49Z</dc:date>
    <item>
      <title>EG: Task skipped, looping over Items in process flow (VBA SASEGObjectModel)</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Task-skipped-looping-over-Items-in-process-flow-VBA/m-p/623088#M35500</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using this code, when I loop through objects in a process flow, I find that certain objects, specifically tasks, are skipped.&amp;nbsp; In this recent instance (I have not provided the EGP file)&amp;nbsp; the code below opened and recognized all the other objects and created a message box output ("Unsorted&amp;lt;--"...) relaying their name, but not so for the "Summary Tables" task.&amp;nbsp; Another version of the code outputs the code of program nodes and query builder objects, successfully; I would also like to access &lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;code &lt;/SPAN&gt;connected to tasks as well.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Because I'm not getting a "item.Name" or an&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: transparent; color: #333333; cursor: text; font-family: 'HelevticaNeue-light','Helvetica Neue',Helvetica,Arial,sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;"item.Type"&lt;/SPAN&gt; from the task, does that mean the task is not in the process flow container?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And its hard to search for this type of question, forgive me if its repeated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Code is run using Excel VBA; Code is based on&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/4"&gt;@ChrisHemedinger&lt;/a&gt; 's code, published &lt;A href="https://github.com/cjdinger/sas-eg-automation/blob/master/vbscript/ExtractCode.vbs" target="_self"&gt;here&lt;/A&gt;:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Option Explicit
Dim Application ' As SASEGuide.Application

Sub EGPConvert_v8()
  Dim Project
  
  ' Change if running a different version of EG
  Dim egVersion
  egVersion = "SASEGObjectModel.Application.8.1"
  
  Dim item
  Dim flow
  Dim Unsorted
  Dim Items_Sorted
  Dim outputFilename As String
  Dim i As Integer
  Dim EGPfile As String
  Dim programsFolder As String
  Dim objFS 'As "Scripting.FileSystemObject"
  Dim objOutFile ' As TextStream
&lt;BR /&gt;  '******************************************************** &lt;BR /&gt;  ' Get...&lt;BR /&gt;  EGPfile = Interface.Get_FileName() 'File name and path
  programsFolder = Interface.Get_Destination() 'Folder path
    
  '********************************************************
  ' Create a new SAS Enterprise Guide automation session
  On Error Resume Next
  Set Application = CreateObject(egVersion)
  If Err.Number &amp;lt;&amp;gt; 0 Then
    MsgBox "ERROR: Need help with 'Set Application = CreateObject(egVersion)"
    End
  End If
   MsgBox Application.Name &amp;amp; ", Version: " &amp;amp; Application.Version &amp;amp; vbCrLf &amp;amp; "Opening project: " &amp;amp; EGPfile
  
  '********************************************************
  ' Open the EGP file with the Application
  Set Project = Application.Open(EGPfile, "")
  If Err.Number &amp;lt;&amp;gt; 0 Then
    MsgBox "ERROR: Unable to open " &amp;amp; EGPfile &amp;amp; " as a project file"
      End
  End If
  
  '********************************************************
  'Open the output file
  MkDir programsFolder &amp;amp; Project.Name
  outputFilename = programsFolder &amp;amp; Project.Name &amp;amp; "\" &amp;amp; Project.Name &amp;amp; ".sas"
  'MsgBox "saving code to " &amp;amp; vbCrLf &amp;amp; outputFilename
  
  Set objFS = CreateObject("Scripting.FileSystemObject")
  Set objOutFile = objFS.CreateTextFile(outputFilename, True)
  
  '********************************************************
  'Prepare the unsorted list
  Set Unsorted = CreateObject("System.Collections.ArrayList")
  
  '********************************************************
  ' Navigate the process flows in the Project object
  For Each flow In Project.ContainerCollection
    ' ProcessFlow is ContainerType of 0
    If flow.ContainerType = 0 Then
        'MsgBox "Process Flow: " &amp;amp; flow.Name
    ' Navigate the items in each process flow
    For Each item In flow.Items
      MsgBox "=Unsorted&amp;lt;--" &amp;amp; item.Name &amp;amp; " Type: " &amp;amp; item.Type
      Unsorted.Add item
    Next
    End If
  Next&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2020 15:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/EG-Task-skipped-looping-over-Items-in-process-flow-VBA/m-p/623088#M35500</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2020-02-07T15:53:49Z</dc:date>
    </item>
  </channel>
</rss>

