3 Replies Latest reply: Sep 8, 2015 5:08 AM by Андрей Жданов RSS

    Execute macro from script

      Hello. I want to load data from 1C (Russian ERP). So, I use this macro:

       

      sub v82query

      Dim ServerName

      Dim InfoBaseName

      Dim InfoBasesAdminName

      Dim InfoBasesAdminPass

      ServerName = ""

      InfoBaseName = "

      InfoBasesAdminName = "

      InfoBasesAdminPass = ""

      set conn = CreateObject("V83.COMConnector.1")

      Set v82 = conn.Connect("Srvr=""" + ServerName + """;Ref=""" + InfoBaseName + """;Usr=""" + InfoBasesAdminName + """;Pwd=""" + InfoBasesAdminPass + """;")

       

      query_1c = "ВЫБРАТЬ" &_

      " Представление(цТребованиеНакладнаяДляСХМатериалы.Поле) Как  Pole"& vbNewLine & _

      "ИЗ"& vbNewLine & _

      " Документ.цТребованиеНакладнаяДляСХ.Материалы КАК цТребованиеНакладнаяДляСХМатериалы " & vbNewLine & _

       

      set v8query = v82.NewObject("Query")

      v8query.text = query_1c

      set result = v8query.Execute

      set m = result.Choose

      do while m.next

      set sql_string = ActiveDocument.DynamicUpdateCommand("INSERT INTO * "& vbNewLine & _

      "(Pole) " & vbNewLine & _

      "VALUES (" & m.Pole &")")

      loop

      ActiveDocument.GetApplication.Refresh

      end sub

       

      And I use a simple script:

      Table1:

      LOAD * INLINE [

          Pole

      ];

       

      left join

      Table2:

      LOAD  C as Pole

      FROM

      [C:\Users\uazhdan\Desktop\Мониторинг_new\Холдинги (поля СПР-1С).xlsx]

       

       

      And I want to call my macro from script, because I try to dynamic update Table1 and left join Table2.

      Please, help me, how to call my macro from my script before left join?