title: Alternative to Application.LoadFromText for MS Access Queries
body: <p>I am attempting to load from text files, queries into an MS Access Queries Collection using VBScript. I am using something like this:
   The code originated from <a href="https://stackoverflow.com/questions/187506/how-do-you-use-version-control-with-access-development">Here</a>.</p>
  
  <pre><code> for each myFile in folder.Files
      objecttype = fso.GetExtensionName(myFile.Name)
      objectname = fso.GetBaseName(myFile.Name)
      WScript.Echo "  " &amp; objectname &amp; " (" &amp; objecttype &amp; ")"
  
      if (objecttype = "form") then
          oApplication.LoadFromText acForm, objectname, myFile.Path
      elseif (objecttype = "bas") then
          oApplication.LoadFromText acModule, objectname, myFile.Path
      elseif (objecttype = "mac") then
          oApplication.LoadFromText acMacro, objectname, myFile.Path
      elseif (objecttype = "report") then
          oApplication.LoadFromText acReport, objectname, myFile.Path
      elseif (objecttype = "sql") then
          'oApplication.LoadFromText acQuery, objectname, myFile.Path
          ' Add create querydef code here
      end if
  
   next
  </code></pre>
  
  <p>But I am unsure how to create a query definition using VBScript.</p>
  
  <p>Any ideas?</p>
  
  <p>Note:
  I originally Exported to the file using something like this:</p>
  
  <pre><code>For Each myObj In oApplication.CurrentDb.QueryDefs 
     Set f = fso.CreateTextFile(sExportpath &amp; "\" &amp; myObj.Name &amp; ".sql", True) 
     f.WriteLine(myObj.SQL) 
     f.Close 
  Next
  </code></pre>