Propósito

✔ Programação GLOBAL® - Quaisquer soluções e/ou desenvolvimento de aplicações pessoais, ou da empresa, que não constem neste Blog devem ser tratados como consultoria freelance. Queiram contatar-nos: brazilsalesforceeffectiveness@gmail.com | ESTE BLOG NÃO SE RESPONSABILIZA POR QUAISQUER DANOS PROVENIENTES DO USO DOS CÓDIGOS AQUI POSTADOS EM APLICAÇÕES PESSOAIS OU DE TERCEIROS.

.: Vitrine

Carregando artigos...

Views

Mostrando postagens com marcador server. Mostrar todas as postagens
Mostrando postagens com marcador server. Mostrar todas as postagens

VBA Outlook 2010 - Visualizando as propriedades do Servidor Exchange - View Exchange Server Properties




Este exemplo demonstra as propriedades novas e aprimoradas que fornecem informações sobre o Servidor Exchange para a conta conectada no Microsoft Outlook 2010.

Esta amostra pode ser incorporado diretamente em seu código.

O Outlook 2010 fornece suporte para termos contas de vários Servidores Exchange em um único perfil.

A coleção de novas contas fora da Session Object fornece acesso aos objetos de Conta. Por sua vez, esses casos foram aprimorados com novas propriedades que fornecem informações sobre o Servidor Exchange a qual a conta está conectada. 

Para testar este código, você precisa ao menos de uma conta no Exchange (duas ou mais é preferido).

Abra o editor de VBA e cole o código no módulo ThisOutlookSession existente.

Abra a janela de visualização imediata e com o cursor dentro deste método, pressione F5.

Sub GetMultipleExchangeAccounts() 
     
    Dim host As Outlook.Application 
    Set host = ThisOutlookSession.Application 
         
    ' Check for Outlook 2010 
    If Left(host.Version, 2) = "14" Then 
        Dim acct As Outlook.Account 
        Dim col As New VBA.Collection 
         
        ' Enumerate the list of accounts looking for 
        ' those that are Exchange Server accounts 
        ' If an account is found, add it to a 
        ' collection to be used later. 
        For Each acct In host.Session.Accounts 
            If acct.AccountType = olExchange Then 
                col.Add acct 
            End If 
        Next 
         
        ' Did the code find any accounts of the type olExchange? 
        If col.Count > 0 Then 
            For Each acct In col 
                Debug.Print "ExchangeMailboxServerName: " & acct.ExchangeMailboxServerName 
                Debug.Print "  AutoDiscoverConnectionMode: " & acct.AutoDiscoverConnectionMode 
                ' The following property returns a fairly large XML document 
                ' uncomment if you wish to see this data. 
                ' Debug.Print "  AutoDiscoverXml: " & acct.AutoDiscoverXml 
                Debug.Print "  CurrentUser: " & acct.CurrentUser 
                Debug.Print "  DeliveryStore: " & acct.DeliveryStore 
                Debug.Print "  ExchangeConnectionMode: " & acct.ExchangeConnectionMode 
                Debug.Print "  ExchangeMailboxServerVersion: " & acct.ExchangeMailboxServerVersion 
            Next 
        Else 
            MsgBox "You do not have any accounts configured to use an Exchange Server." 
        End If 
    Else 
        MsgBox "This code only works with Outlook 2010." 
    End If 
End Sub


Tags: VBA, Outlook, Exchange, Server, Properties, Outlook.ExchangeAccounts



VBA Access Basic - Usando o OLEDB para conectar arquivos MDB - Use OLEDB to connect with mdb file

Conectando arquivos MDB.

Segue:


'Microsoft ActiveX Data Objects Recordset 2.7 Library
Sub ConnectionExample1()
   Dim conn As ADODB.Connection
   Set conn = New ADODB.Connection

   With conn
      Let .Provider = "Microsoft.Jet.OLEDB.4.0;"
      Let .ConnectionString = "Data Source=" & _
        CurrentProject.Path & "\mydb.mdb"
   End With

   conn.Open

   MsgBox "Conexão foi aberta!"

   conn.Close

   Set conn = Nothing

   MsgBox "Conexão foi Fechada!"
End Sub

Tags: VBA, Access, connect, SQL, database,  Connecting, Server, Data Source, ADODB, SQLOLEDB, MDB,


VBA Access Basic - Abrindo um banco de dados no modo READ ONLY - Opening a Database in Read-Only Mode

Abrindo um banco de dados no modo READ ONLY.

Segue:

Sub Open_ReadOnly()
   Dim conn As ADODB.Connection
   Dim strDb As String

   On Error GoTo ErrorHandler

   Let strDb = CurrentProject.Path & "\Bernardess\mydb.mdb"

   Set conn = New ADODB.Connection

   With conn
      Let .Provider = "Microsoft.Jet.OLEDB.4.0;"
      Let .Mode = adModeRead
      Let .ConnectionString = "Data Source=" & strDb

      .Open
   End With

   Debug.Print "O banco de dados foi aberto como acesso read-only."

   conn.Close

   Set conn = Nothing

   Debug.Print "Database was closed."
   Exit Sub

ErrorHandler:
   MsgBox Err.Number & ": " & Err.Description
End Sub



Tags: VBA, Access, connect, SQL, database,  Connecting, Server, Data Source, Opening, Read-Only Mode,


VBA Access Basic - Conectando um Banco de Dados através da URL - Connect to database through URL

Conectando um Banco de Dados com Segurança em Nível de Usuário.

Segue:

Sub ConnectToURL()
  On Error GoTo Except
    Dim Connection As New ADODB.Connection

    Connection.Provider = "Microsoft.Jet.OLEDB.4.0"

    Const URL = "http://localhost/access/nwind.mdb"

    Let Connection.ConnectionString = "URL=" & URL
    Let Connection.Mode = adModeReadWrite

    Connection.Open

    MsgBox "Conectado via " & Connection.Provider & _
        "Provedor OLE DB!", vbInformation
    Exit Sub

Except:
    MsgBox Err.Description, vbCritical
End Sub


Tags: VBA, Access, connect, SQL, database, Connecting, Server, Data Source, OLE DB, Opening, URL, 


VBA Access Basic - Conectando um Servidor SQL Server sem o DSN - Connecting to an SQL Server Using a DSN-less Connection

Conectar bancos de dados de SQL é uma rotina comum. Como fazê-lo?

Segue:

Sub Connect_ToSQLServer()
   Dim conn As ADODB.Connection

   Set conn = New ADODB.Connection

   
With conn
      ' Sem o DSN conectamos usando o driver ODBC
      ' (modifique a informação do Data Source como mostrado abaixo)

      
.Open "Driver={SQL Server};" & _
          "Server=192.128.1.100;" & _
          "UID=myId;" & _
          "PWD=myPassword;" & _
          "Database=SupportDb"
      .Close
   End With

   
Set conn = Nothing
End Sub

Tags: VBA, Access, connect, SQL, database,  Connecting, Server, Data Source, ADODB, SQLOLEDB, DSN, ODBC


VBA Access Basic - Conectando um Banco de Dados com Nome e Usuário - Connect to database with user name and password

Conectando um Banco de Dados com Segurança em Nível de Usuário.

Segue:


Sub addUser() 
   Dim myConnection As ADOX.Catalog
   Dim newUser As ADOX.User
   Dim userName As String
   Dim newPassword As String
   
   Set myConnection = New ADOX.Catalog

   myConnection.ActiveConnection = _
        "Provider = Microsoft.Jet.OLEDB.4.0;" & _
        "Data Source=C:\r.mdb;" & _
        "Jet OLEDB:System database=C:\Bernardess\r.mdw;" & _
        "User id=john;Password=;"

   Set newUser = New ADOX.User

   newUser.Name = userName

   myConnection.Users.Append newUser
   myConnection.Users(newUser.Name).changePassword "", newPassword
End Sub

Tags: VBA, Access, connect, SQL, database, Connecting, Server, Data Source, ADOX, Opening, Secured, User Level, Conectando, Banco de Dados, Nome, Usuário, user, name, password


VBA Access Basic - Abrindo um Banco de Dados com Segurança em Nível de Usuário - Opening a Database Secured at the User Level

Conectando um Banco de Dados com Segurança em Nível de Usuário.

Segue:

Sub Open_WithUserSecurity()
   Dim conn As ADODB.Connection
   Dim strDb As String
   Dim strSysDb As String

   On Error GoTo ErrorHandler

   strDb = CurrentProject.Path & "\Bernardess\mydb.mdb"
   strSysDb = CurrentProject.Path & "\Security.mdw"
   Set conn = New ADODB.Connection

   With conn
      .Provider = "Microsoft.Jet.OLEDB.4.0;"
      .ConnectionString = "Data Source=" & strDb & ";" & _
         "Jet OLEDB:System Database=" & strSysDb
      .Open , "Developer", "WebMaster"
   End With

   conn.Close

   Set conn = Nothing

   Exit Sub

ErrorHandler:
   MsgBox Err.Number & ": " & Err.Description

End Sub



Tags: VBA, Access, connect, SQL, database, Connecting, Server, Data Source, Opening, Secured, User Level,

VBA Access Basic - Abrindo um Banco de Dados no modo Leitura/Gravação - Opening a Database in Read/Write Mode

Abrindo um Banco de Dados no modo Leitura/Gravação.

Segue:

Sub Open_ReadWrite()
   Dim conn As ADODB.Connection
   Dim strDb As String

   On Error GoTo ErrorHandler
   strDb = CurrentProject.Path & "\mydb.mdb"
   Set conn = New ADODB.Connection

   With conn
      .Provider = "Microsoft.Jet.OLEDB.4.0;"
      .Mode = adModeReadWrite
      .ConnectionString = "Data Source=" & strDb
      .Open
   End With
   Debug.Print "Connection was opened."

   conn.Close
   Set conn = Nothing
   Debug.Print "Connection was closed."

   Exit Sub
ErrorHandler:
   Debug.Print Err.Number & ": " & Err.Description
End Sub

Tags: VBA, Access, connect, SQL, database,  Connecting, Server, Data Source, Opening, Read/Write Mode, Read, Write


VBA Access - Abrindo um Banco de Dados protegido com Senha - Opening a Password-Protected Database

Abrindo um Banco de Dados protegido com Senha.

Segue:

Sub Open_WithDbPassword()
   Dim conn As ADODB.Connection
   Dim strDb As String

   On Error GoTo ErrorHandler

   Let strDb = CurrentProject.Path & "\Bernardess\mydb.mdb"
   Set conn = New ADODB.Connection

   With conn
      Let .Provider = "Microsoft.Jet.OLEDB.4.0;"
      Let .ConnectionString = "Data Source=" & strDb & ";" & _
           "Jet OLEDB:Database Password=secret;"
      .Open
   End With

   Debug.Print "Banco de dados protegido está aberto"

   conn.Close

   Set conn = Nothing

   Debug.Print "Database was closed."
   Exit Sub

ErrorHandler:
   MsgBox Err.Number & ": " & Err.Description
End Sub

Tags: VBA, Access, connect, SQL, database,  Connecting, Server, Data Source, Opening, Password, Protected, senha, protegido, 


VBA Access Basic - Conectando um Servidor de Banco de Dados SQL - Connecting to an SQL Server Database

Conectar bancos de dados de SQL é uma rotina comum. Como fazê-lo?

Segue:

Sub ConnectToSQL_SQLOLEDB()
   Dim conn As ADODB.Connection

   Set conn = New ADODB.Connection

   
With conn
      Let.Provider = "SQLOLEDB"
      
Let.ConnectionString = "Data Source=mySource;" & _
          "database=yourDatabase; UserId=sa; Password=;"
      .Open
   End With

   
If conn.State = adStateOpen Then
      Debug.Print "Conexão estabelecida!"
   End If

   
conn.Close

   
Set conn = Nothing
End Sub

Tags: VBA, Access, connect, SQL, database,  Connecting, Server, Data Source, ADODB, SQLOLEDB, 


diHITT - Notícias