title: Extract XBRL facts to Excel
body: <p>I would like to cycle through several hundreds of XBRL-files automatically and gather certain specific pieces of data and paste them into an excel sheet. I managed to get the "tangential code" working, but cannot answer the core question.</p>
  
  <p>E.g., in the XBRL file I need the value of this fact, reported against the concept <code>pfs:GainLossBeforeTaxes</code>:</p>
  
  <pre><code>&lt;pfs:GainLossBeforeTaxes
      unitRef="U-EUR"
      decimals="INF" 
      contextRef="CurrentDuration"&gt;1091134.68&lt;/pfs:GainLossBeforeTaxes&gt;
  </code></pre>
  
  <p>==> I need to obtain 1091134.68 </p>
  
  <p>This is doubtlessly something which is easy with Regex, but I cannot seem to get this working. And time constraints are also a thing for me, so I would like to obtain some sort of minimal viable product so far and later on expand that, but at this point the code is more of a means to an end, rather than the endproduct (analysis) itself.</p>
  
  <p>So far, I came up with the following:</p>
  
  <pre><code>Sub EDI_Input()
  
  Dim myFile As String
  Dim textline As String
  Dim StartPos As Integer
  Dim EndPos As Integer
  
  myFile = Application.GetOpenFilename()
  
  Open myFile For Input As #EDI
  Do Until EOF(EDI)
  Line Input #EDI, textline
  
  
  If InStr(textline, "NonRecurringFinancialCharges") &lt;&gt; 0 And InStr(textline, "CurrentDuration") &lt;&gt; 0 Then
  
  Endpos = InStr(textline, "&lt;/pfs:NonRecurringFinancialCharges&gt;&lt;")
  
  
  result = Left(textline, Endpos - 1)
  StartPos = InStr(textline, "Char(34)&amp;CurrentDuration&amp;Char(34)&amp;&gt;")
  textline = Left(textline, StartPos + 18)
  Debug.Print (textline)
  
  End If
  
  Loop 
  </code></pre>
  
  <p>I keep stumbling on the "invalid call procedure or argument error", possible because I load to many data in my string.</p>
  
  <p>Anybody who has any opinion on how to get at least a partially working programma - in that way I can at least partially start my analysis - Or a tutorial for beginners/experience with this problem?</p>