-
Nov 22nd, 2019, 03:23 AM
#1
Thread Starter
Addicted Member
How to create Access.Application object?
The application written in VB6 run this code:
Code:
Private Sub Image7_Click()
Dim objaccess As Access.Application
Set objaccess = CreateObject("Access.Application")
objaccess.OpenCurrentDatabase "MyAccessDB.mdb"
objaccess.DoCmd.RunMacro "SomeMacro"
objaccess.DoCmd.Maximize
End Sub
However the application fails with the error message:
Code:
"Run time error '429', ActiveX component can't create object"
Is this message related to the library msacc9.olb or some other library?
Do I need to register some library with Windows 7?
Or what should I do?
-
Nov 22nd, 2019, 03:45 AM
#2
Re: How to create Access.Application object?
is microsoft access installed?
i guess it is, else you would have some other error
create object should work without any reference to access, but as you have a reference you could try
Code:
set objaccess = new access.application
note: the reference must match the version of the installed access, for either method
for further information see
https://docs.microsoft.com/en-us/off...ss.application
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 22nd, 2019, 03:52 AM
#3
Re: How to create Access.Application object?
Use
Code:
Dim objaccess As Object
-
Nov 22nd, 2019, 06:46 AM
#4
Thread Starter
Addicted Member
Re: How to create Access.Application object?
@westconn1 No. Its a virtual machine with Windows 7, 32 bit. I don't have the right to install MS Office since I am not an admin. Its a problem with the licenses. I don't think they will allow me use even VirtualBox and Windows 7. I had my own copy
Hmm, if I have the name of the DLL or OCX I need to add to the virtual machine... I have MS Office 2000 installed on the host PC.
Which MS Access 2000 OLB, DLL or OCX file should I copy to my virtual machine installation for this VBA code to work?
But i already have msacc9.olb included which should be "Microsoft Access 9.0 Object Library"
Last edited by kutlesh; Nov 22nd, 2019 at 07:02 AM.
-
Nov 22nd, 2019, 08:35 AM
#5
Re: How to create Access.Application object?
Not sure what you are attempting to do here. If you want to work with the data in and mdb then you can do that without Access and without using anything related to the access application object.
If on the other hand you are trying to automate access and use its features then you must have Access installed on the system or in this case the VM. You can't automate something that doesn't exist.
-
Nov 22nd, 2019, 08:58 AM
#6
Re: How to create Access.Application object?
Hi,
I created a Makro to export a Table to a Textfile, this is an old Access 2000 Database
I do however have Access 2010 Installed, so it might not work with you situation
see if it helps
Code:
Dim AccessApp As Access.Application
Private Sub Command1_Click()
On Error Resume Next
Set AccessApp = New Access.Application
With AccessApp
.OpenCurrentDatabase "D:\SE.mdb"
.RunCommand acCmdWindowHide
.Application.Visible = False
.DoCmd.RunMacro "Makro1"
MsgBox "done !"
.CurrentDb.Close
.Quit
End With
On Error Resume Next
With AccessApp
.CurrentDb.Close
.Quit
End With
End Sub
what does the Makro do anyway?
to hunt a species to extinction is not logical !
since 2010 the number of Tigers are rising again in 2016 - 3900 were counted. with Baby Callas it's 3901, my wife and I had 2-3 months the privilege of raising a Baby Tiger.
-
Nov 22nd, 2019, 03:03 PM
#7
Re: How to create Access.Application object?
An OLB is just a TLB, and they don't contain any object code. They are basically just precompiled source code for definitions of flat calls, interfaces, and constants. When you use late-binding as somebody is indirectly suggesting above only the flat calls and constant definitions are of much use, and I don't think this one even has any flat call definitions anyway.
Access.Application is an ActiveX EXE, in this case MS Access. So without installing MS Access there is no way you can run it, which is what your code is trying to do.
-
Nov 22nd, 2019, 04:52 PM
#8
Re: How to create Access.Application object?
you could try using visdata that is installed as part of vb6, BUT it is not Access
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|