Below are the cases i tried to create object of instance "COMAdmin.COMAdminCatalogCollection".
But I`m getting error saying:
"Microsoft VBScript runtime error: ActiveX component can't create object: 'COMAdminCatalogCollection'"
Code:
dim aa,bb,cc
set aa = new ActiveXObject("COMAdmin.COMAdminCatalogCollection")
'Set bb = Createobject("COMAdmin.COMAdminCatalogCollection")
'set cc = Createobject("COMAdminCatalogCollection")
I dont have any idea about the instance "COMAdmin.COMAdminCatalogCollection", I tried to find dlls to register to fix the issue I got nothing on internet.
Thanks in advance.
Try to get Collection from COMAdminCatalog
Set objCatalog = CreateObject("COMAdmin.COMAdminCatalog")
Set oTSCol = objCatalog.GetCollection("TransientSubscriptions")
Set objCatalog = nothing
Related
I use UFT 11.53, Windows 8.1 Pro et vbscripts.
I've a question : Is it possible to add objects to an object repository automatically using VBScript?
My problem : I've an application in which I've to automate tests and qualifications. I would like to add an new object (using vbscript) to my repository object.
Below is my code which I tried:
Dim RepositoryFrom
Dim ParentObject
ObjectRepositoryPath="D:\repository.tsr"
'Creating Object Repository utility Object
Set RepositoryFrom = CreateObject("Mercury.ObjectRepositoryUtil")
'Load Object Repository
RepositoryFrom.Load ObjectRepositoryPath
Set oWebElement = WebElement(""&str) 'str = "PR1500073LRBA", it's an element of my table
Set ParentObject = Browser("fia").Page("fia_3")
RepositoryFrom.AddObject oWebElement, ParentObject, "reference"
RepositoryFrom.Save
Set RepositoryFrom = nothing
Set oWebElement = nothing
Set oParent = nothing
With this code, I've an message error :
'AddObject' - General error.
Line (63): "RepositoryFrom.AddObject oWebElement, ParentObject, "reference"".
Do you know why I've this message ?
Thanks :)
Good day sirs. I'm trying to retrieve a photo from my access database then load it in a PictureBox but I have this kind of problem which I can't resolve.
I have seen questions similar to mine but I can't understand the solutions given by others as I'm just a newbie. Will someone please help me correct my codes for retrieving image file from access database. Thanks
I'm using access database and Visual Basic 2010.
Here's the code:
Dim arrImage() As Byte
Dim myMS As New IO.MemoryStream
Dim da As New OleDb.OleDbDataAdapter("SELECT *
FROM tblEmp
WHERE EmployeeID= '"
& Me.txtID.Text
& "'", con)
Dim dt As New DataTable
da.Fill(dt)
If dt.Rows.Count > 0 Then
If Not IsDBNull(dt.Rows(0).Item("Picture")) Then
arrImage = dt.Rows(0).Item("Picture")
For Each ar As Byte In arrImage
myMS.WriteByte(ar)
Next
'
inFrm.PictureBox1.Image = Image.FromStream(myMS)
End If
End If
I'm getting a "Parameter is not valid" error from the line
inFrm.PictureBox1.Image = Image.FromStream(myMS)
try replacing the line of code with this
inFrm.PictureBox1.PictureData = myMS.Read
objWriteWorkbook.sheets.add ,objWriteWorkbook.sheets(objWriteWorkbook.sheets.count)
Set NewWorksheetObject = objWriteWorkbook.Worksheets(num)
objWriteWorkbook.Sheets(num).Name = sheetName
I wanted to change the name of added worksheet.
Adding of sheet and object creation for that sheet is working fine but when I try to change the name of the sheet I am getting an error "Unknown runtime error"
Can any one help how can change the name of added sheet.
Assign the new sheet to a variable when you add it:
Set ws = wb.Sheets.Add(, wb.Sheets(wb.Sheets.Count))
ws.Name = sheetName
set xlo=CreateObject("excel.application")
set wbo=xlo.workbooks.open("C:\Users\XXX\Desktop\Temp.xlsx")
Set ws = wbo.Sheets.Add(, wbo.Sheets("sheet1"))
ws.Name = "Priyesh"
wbo.save
wbo.close
xlo.quit
set wbo=nothing
set xlo=Nothing
When I run the code, I get an error saying
ActiveX component can't create object: 'Shell.LocalMachine'
Class MachineName
Private internal_ComputerName
Public Function SetMachineName
Set objComputer = CreateObject("Shell.LocalMachine")
internal_ComputerName = objComputer.MachineName
End Function
Public Property Get GetMachineName
GetMachineName = internal_ComputerName
End Property
End Class
Dim objMachine
Set objMachine = New MachineName
objMachine.SetMachineName
thanks for this. I am having the same problems when using this Shell.Localmachine on my windows 7 64 bit machine when i try to run a simple vbscript code. I had to default to WScript.Network instead:
'just a test script
'set objComputer = CreateObject("Shell.LocalMachine")
'wscript.echo "computer name" & objcomputer.machinename
Set objWshNet = CreateObject("WScript.Network")
wscript.echo "computer name : " & objwshnet.computername
Morbo said "Must admit I hadn't come across that object before. I'd normally create a "WScript.Network" object and get the ComputerName property. If you're diagnosing "Shell.LocalMachine" I can tell you that on my copy of XP it is provided by system32\shgina.dll"
I have a vbscript that creates a registry entry on a Windows Server 2003 machine. This script has been working fine for about a year now, but recently it just stopped working. I am thinking that a windows update must have changed something, maybe a security setting, whereby this script is no longer permitted to execute. The script uses the following function to create an entry in HKEY_LOCAL_MACHINE\SOFTWARE\ODBC\ODBC.INI\ for new ODBC connections:
Function CreateRegKey (sComputer, hTree, sKey)
Dim oRegistry
Dim lResult
Set oRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}//" & sComputer & "/root/default:StdRegProv")
lResult = oRegistry.CreateKey(hTree, sKey)
If (lResult = 0) And (Err.Number = 0) Then
CreateRegKey = 0
Else
CreateRegKey = 1
msgbox("Create Key " & sKey & " Failed")
End If
Set oRegistry = Nothing
End Function
This function is called as follows:
Const HKEY_LOCAL_MACHINE = &H80000002
sPath = "SOFTWARE\ODBC\ODBC.INI\" & DataSourceName
'Create ODBC entry
If (0 = CreateRegKey(sComputer, HKEY_LOCAL_MACHINE, sPath)) Then
....
Else
....
End If
Does anyone know of a windows update that could have caused this script to suddenly stop working? The script stops on the following line:
lResult = oRegistry.CreateKey(hTree, sKey)
It does not give an error or anything. It just stops on that line.
Anyone got an idea what is going wrong here and how I could fix it? Thanks.
EDIT: I now get the error number returned by CreateKey. It returns the following:
Err.Number: -2147023533
Err.Description: Cannot start a new logon session with an ID that is already in use
Does anyone know what is causing this and how to work around it? Thanks.
The description for the error code -2147023533 (0x80070553) is:
Cannot start a new logon session with an ID that is already in use.
A search for this code and description reveals:
hotfix KB2283089 for fixing the error,
an assumption that the error is caused by KB979683,
a suggestion to reinstall service packs in order to fix the error.
Give these a try and see if it helps.