0

I am trying to open a form in an access database using powershell:

$application = New-Object -ComObject Access.Application
$Fullpath = "path.accdb"
$application.OpenCurrentDataBase($Fullpath)
$application.docmd.OpenForm("frm")

I am getting the following error message:

Exception calling "OpenCurrentDatabase" with "1" argument(s): "Unable to cast COM object of type 'Microsoft.Office.Interop.Access.ApplicationClass' to interface type 'Microsoft.Office.Interop.Access._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{68CCE6C0-6129-101B-AF4E-00AA003F0F07}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

Has anyone seen this before/resolved this issue?

1

2 Answers 2

1

A bit late now, but for the sake of following up...

Did you check that your path was what it should've been?

It seems you were trying to open something that was not an access application but an _Application interface object (Word, Outlook, Excel perhaps?)

"Unable to cast COM object of type >'Microsoft.Office.Interop.Access.ApplicationClass' to interface type >'Microsoft.Office.Interop.Access._Application)'.

I would start with something like this:

$Fullpath = "path.accdb"
echo $Fullpath
$application = New-Object -ComObject Access.Application
$application.OpenCurrentDataBase($Fullpath)
$application.docmd.OpenForm("frm")

Better late than never, maybe it helps down the line.

Sign up to request clarification or add additional context in comments.

Comments

0

I want you to try this.. I made this code and its working fine

$Db = "sampledb.mdb"
$cursor = 3 
$lock = 3

$conn = New-Object -ComObject ADODB.Connection 
$recordset = New-Object -ComObject ADODB.Recordset
$conn.Open("Provider=Microsoft.Ace.OLEDB.12.0;Data Source=$Db")

$query = "Select * from LoginInfo"
$recordset.open($query,$conn,$cursor,$lock)

$recordset.Addnew() 
$recordset.Fields.Item("EmpID") = "1" 
$recordset.Fields.Item("UserName") = $username_txt.Text
$recordset.Fields.Item("PWord") = $password_txt.Text
$recordset.Fields.Item("EmpRole") = $userrole_combo.SelectedItem

$recordset.Update()
$recordset.close() 
$conn.close()

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.