Thread View: pl.comp.lang.vbasic
1 messages
1 total messages
Started by Maciej Franciszkowski
Fri, 10 Dec 2010 10:44
automatyzacja Accessa z poziomu VB.NET
Author: Maciej Franciszkowski
Date: Fri, 10 Dec 2010 10:44
Date: Fri, 10 Dec 2010 10:44
76 lines
3353 bytes
3353 bytes
witam
próbuję wysłąć raport przez automatyzację
doszedłem do komunikatu że nie można wywołać Active-X
poniżej jest kod, który modyfikuję. Tak naprawdę wcale nie chciabym
aplikacji
Accessowej wywoływać, tylko wysłać z niej raport emailem.
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
Z góry dziękuję za podpowiedzi
MF
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads