0
votes

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")
1
You're running VBScript in Python so you figured that you'd tag the question VB.NET? Please don't spam tags. - jmcilhinney
Oo.. Did I ? .. Am sorry . I didnt see - Muneeb K
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. Chances are Python is running using opposite architecture to where the COM DLL is registered. - user692942
May be.. but tried alot finally converted to exe. now it works. - Muneeb K

1 Answers

0
votes

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/