Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Automation of MS Access from VB.NET

0 views
Skip to first unread message

Maciej Franciszkowski

unread,
Dec 10, 2010, 8:56:49 AM12/10/10
to

I'am trying to sort out the Access automation issue (Console
application)
Open raport, print raport, send raport by email (in vba
DoCmd.SendObject)

But now get an error "Active-x not found"

cod is below:

Private Declare Sub Sleep Lib "Kernel32" (ByVal dwMS As
Long)
Private Sub accAuth()
Dim accObj As Object, Msg As String
Dim application As String, dbs As String, workgroup As
String
Dim user As String, password As String, cTries As
Integer
Dim x

' This is the default location of Access
application = "C:\Program Files\Microsoft Office
\Office11\MSACCESS.EXE"
' Use the path and name of a secured MDB on your
system
dbs = "C:\Plan\Baza.mdb"
' This is the default workgroup
workgroup = "C:\Plan\System.mdw "
user = "user" ' Use a valid username
password = "pass" ' and correct password


x = Shell(application & " " & Chr(34) & dbs & Chr(34)
& " /nostartup /user " & user & _
" /pwd " & password & " /wrkgrp " & Chr(34) &
workgroup & Chr(34), vbMinimizedFocus)


'On Error GoTo WAITFORACCESS
accObj = GetObject(, "Access.Application")


' Turn off error handling
On Error GoTo 0

' You can now use the accObj reference to automate
Access


Msg = "Access is now open. You can click on Microsoft
Access "
Msg = Msg & "in the Taskbar to see that your database
is open."
Msg = Msg & vbCrLf & vbCrLf & "When ready, click OK to
close."
Console.WriteLine(Msg)


accObj.CloseCurrentDatabase()
accObj.Quit()

accObj = Nothing
Console.WriteLine("All Done!")

'Exit Sub
.....


Thannk you in advance!

Maciej Franciszkowski

0 new messages