0

Well I am calling a VBScript inside a python code. I get error "ActiveX component can't create object" But it is fine When I call Seperate (When I double click that or run using cmd).

This is part of python code. I tried csript, wscript. changed the path to system32 / SYSVOW64.. But nothing is working

for i in range(printInput):
    print("range")
    print(i)
    os.system(r"C:\Windows\system32\cmd.exe /k c:\windows\SysWOW64\cscript.exe  C:\Users\muneeb.kalathil\PycharmProjects\moodledownload\vcconverter\labelprint\new.vbs")
    #subprocess.call("run.bat")

And this is VBSscript

'<SCRIPT LANGUAGE="VBScript">
    ' Data Folder
    Const sDataFolder = "C:\Users\muneeb.kalathil\PycharmProjects\moodledownload\vcconverter\labelprint\"
    DoPrint(sDataFolder & "label.lbx")

    '*******************************************************************
    '   Print Module
    '*******************************************************************
    Sub DoPrint(strFilePath)
        Set ObjDoc = CreateObject("bpac.Document")
        bRet = ObjDoc.Open(strFilePath)
        If (bRet <> False) Then
            ObjDoc.GetObject("AssetName").Text = "text"
            ObjDoc.GetObject("AssetTag").Text = "text"
                        ObjDoc.GetObject("company").Text = "text"
                        
                        Call ObjDoc.SetBarcodeData(ObjDoc.GetBarcodeIndex("QR"), "link")

            ' ObjDoc.SetMediaByName ObjDoc.Printer.GetMediaName(), True
            ObjDoc.StartPrint "", 0
            ObjDoc.PrintOut 1, 0
            ObjDoc.EndPrint
            ObjDoc.Close
        End If
        Set ObjDoc = Nothing
    End Sub

It shows the error in

Set ObjDoc = CreateObject("bpac.Document")
jmcilhinney
  • 50,448
  • 5
  • 26
  • 46
Muneeb K
  • 457
  • 1
  • 9
  • 21
  • You're running VBScript in Python so you figured that you'd tag the question VB.NET? Please don't spam tags. – jmcilhinney Jul 28 '20 at 11:46
  • Oo.. Did I ? .. Am sorry . I didnt see – Muneeb K Jul 28 '20 at 11:56
  • 1
    There are two registry hives where COM DLLs are registerable in Windows OS 64-bit. See [Error ASP 0177: 8007007e CreateObject fails for COM DLL](https://stackoverflow.com/a/35985827). Chances are Python is running using opposite architecture to where the COM DLL is registered. – user692942 Jul 28 '20 at 12:40
  • May be.. but tried alot finally converted to exe. now it works. – Muneeb K Aug 05 '20 at 16:06

1 Answers1

0

So after lot of tries, I converted vbscript to exe file and then executed. Now it is working.

os.system("run.exe")

I have used this software as some converters are not really converting to exe. This software has some limitations. But works well for me.

https://www.battoexeconverter.com/

Muneeb K
  • 457
  • 1
  • 9
  • 21