title: vba excel : need to load an xml file and write specific values (got from current) excel then save it
body: <p>am totally new with VBA, xml and general programming, i just tried to get information from many sites, but seems like i am unable to solve my problem, which is:</p>
  
  <p>my target is : For the end user, he has to enter framework path and other useful values into excel file and select run test, then the code will get these values, load and xml file, enter these values into the xml, save it and start application. these values will be used by other script called into the Application.</p>
  
  <p>my pb is that seems like excel is not loading at all the xml (and even continue debugging, he is saying "run time error, unable to find the path specified ; below the code am using and also the xml format:</p>
  
  <pre><code>Option Explicit
  
  Private Sub RunTest_Click()
  Dim envFrmwrkPath As String
  Dim ApplicationName As String
  Dim TestIterationName As String
  Dim objfso, app, Eval As Object
  Dim i, Msgarea
  
  
  
  
  envFrmwrkPath = ActiveSheet.Range("E6").Value
  ApplicationName = ActiveSheet.Range("E4").Value
  TestIterationName = ActiveSheet.Range("E8").Value
  
  
  Set EnvVarXML = CreateObject("Microsoft.XMLDOM")
  
  EnvVarXML.Load (envFrmwrkPath &amp; "Environment\EnvVar.xml")
  
  For Each UIElement In EnvVarXML.SelectNodes("Environment/Variable")
  
          Set Field = Eval(objUIElement.SelectSingleNode("Name").Text)
          Field.Value = UIElement.SelectSingleNode("Value").Text
  
          Set EnvVarXML = CreateObject("Microsoft.XMLDOM")
  
          EnvVarXML.Load (envFrmwrkPath &amp; "Environment\EnvVar.xml")
  
  Next
  
  Set EnvVarXML = Nothing
  
  Set objfso = CreateObject("Scripting.FileSystemObject")
  
  If Not objfso.FolderExists(envFrmwrkPath) Then
  
      MsgBox envFrmwrkPath &amp; "- Folder not found. Setting not saved"
  
      Exit Sub
  
  End If
  
  Set objfso = Nothing
  
  Set EnvVarXML = CreateObject("Microsoft.XMLDOM")
  
  EnvVarXML.Load (envFrmwrkPath &amp; "Environment\EnvVar.xml")
  
  For Each UIElement In EnvVarXML.SelectNodes("Environment/Variable")
  
          Set Field = Eval(UIElement.SelectSingleNode("Name").Text)
  
          UIElement.SelectSingleNode("Value").Text = Field.Value
  
          If UIElement.SelectSingleNode("Name").Text = "envFrmwrkPath" Then
  
              Application.DisplayAlerts = False
  
              Set app = CreateObject("QuickTest.Application")
  
              app.Launch
              app.Visible = True
              app.WindowState = "Maximized"
              app.Open envFrmwrkPath &amp; "\Driver", False
              app.Folders.RemoveAll
              app.Folders.Add (envFrmwrkPath)
              app.Test.Settings.Resources.DataTablePath = "&lt;Default&gt;"
              app.Test.Settings.Resources.Libraries.RemoveAll
  
              app.Test.Settings.Resources.Libraries.Add (envFrmwrkPath &amp; _
                "FunctionLibrary\VTL_Util_Lib.vbs")
  
              app.Test.Settings.Resources.Libraries.Add (envFrmwrkPath &amp; _
                "FunctionLibrary\VTL_BP_Lib.vbs")
  
              app.Test.Settings.Resources.Libraries.Add (envFrmwrkPath &amp; _
                 "FunctionLibrary\VTL_Engine_Lib.vbs")
  
              app.Test.Settings.Resources.Libraries.Add (Field.Value &amp; _
                  "FunctionLibrary\RecoveryScenario.qfl")
  
              If app.Test.Settings.Recovery.Count &gt; 0 Then
                   app.Test.Settings.Recovery.RemoveAll
              End If
  
              app.Options.Run.RunMode = "Fast"
  
              app.Options.Run.ViewResults = False
  
              For i = 1 To app.Test.Actions.Count
                  app.Test.Actions(i).ObjectRepositories.RemoveAll
  
                  app.Test.Actions(i).ObjectRepositories.Add (envFrmwrkPath &amp; _
                             "Ressources\ObjectRepository\shared_repository.tsr")
  
              Next
  
              app.Test.Save
  
          End If
  
      Next
  
      ' here i got the error but the pb is earlier i think!
      EnvVarXML.Save (envFrmwrkPath &amp; "Environment\EnvVar.xml") 
  
  End Sub
  </code></pre>
  
  <p>============</p>
  
  <p>the xml file is like following:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="no"?&gt;
  &lt;Environment&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envversion&lt;/Name&gt;
          &lt;Caption&gt;version :&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;Version&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envAppName&lt;/Name&gt;
          &lt;Caption&gt;Application name :&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;Name of the Application Under Test&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envFrmwrkPath&lt;/Name&gt;
          &lt;Caption&gt;Framework folder path:&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;Path of the automation framework&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envIP&lt;/Name&gt;
          &lt;Caption&gt;IP Address:&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;IP Address&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envLogin&lt;/Name&gt;
          &lt;Caption&gt;Login:&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;Login&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;&lt;/Name&gt;
          &lt;Caption&gt;Password:&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;Password&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envLogs&lt;/Name&gt;
          &lt;Caption&gt;Logs:&lt;/Caption&gt;
          &lt;Type&gt;TEXTAREA&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;logs&lt;/Description&gt;
      &lt;/Variable&gt;
      &lt;Variable&gt;
          &lt;Name&gt;envTestIteration&lt;/Name&gt;
          &lt;Caption&gt;Test iteration name:&lt;/Caption&gt;
          &lt;Type&gt;TEXT&lt;/Type&gt;
          &lt;Value&gt;&lt;/Value&gt;
          &lt;Description&gt;TestIterationName Subfolder to be created&lt;/Description&gt;
      &lt;/Variable&gt;
  &lt;/Environment&gt;
  </code></pre>
  
  <p>=====================</p>
  
  <p>Sorry for the very long text, want to be clear as possible ... i appreciate help on how to resolve this but especially on to understand how to do this at any time. Thanks.</p>