Microsoft Office Tutorials and References
In Depth Information
Creating a Contacts Database
'Table does not exist in database file¶
'Create new table¶
Call CreateTable(objConn)¶
'Set objApp object¶
Set objApp = Outlook.Application¶
'Set NameSpace object¶
Set objNS = objApp.GetNamespace("MAPI")¶
'Set source folder as default Contacts folder¶
Set objFolder = objNS.GetDefaultFolder(olFolderContacts)¶
'Save each contact as a new record in database table¶
For Each objContact In objFolder.Items¶
If objContact.Class = olContact Then¶
Call SaveData(objContact, objConn)¶
i = i + 1¶
End If¶
Next objContact¶
MsgBox i & " contact items have been saved in " & _¶
'Launch Microsoft Access application¶
Call OpenDatabaseInAccess¶
If Err <> 0 Then¶
'Critical error¶
MsgBox Err.Number & "-" & Err.Description, _¶
vbOKOnly + vbExclamation, _¶
End If¶
'Release object variables and free memory¶
Set objApp = Nothing¶
End Sub¶
' * * * * *¶
Private Sub CreateNewAccessDatabase(strFileName As String)¶
'ADODB Catalog Object declaration¶
Dim objDB As Object¶
'Database format¶
Dim intVer As Integer¶
'Create ADODB Catalog object¶
'to create a new database file¶
Set objDB = CreateObject("ADOX.Catalog")¶
intVer = 5 'Access 2000 database file format¶
'Create new database file¶
objDB.Create "Provider=Microsoft.Jet.OLEDB.4.0;" & _¶
"Jet OLEDB:Engine Type=" & intVer & _¶
";Data Source=" & strFileName¶
'Release object variables and free memory¶
Set objDB = Nothing¶
End Sub¶
Search JabSto ::

Custom Search