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 Dll. Mostrar todas as postagens
Mostrando postagens com marcador Dll. Mostrar todas as postagens

VBA Tips - GetComputerName - Sabendo o nome do computador




Tenha acesso ao nome do computador em uso. Essa funcionalidade pode habilitar a sua aplicação para uma conexão automática.
  Private Declare Function GetComputerName Lib "kernel32" Alias _      "GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Deixe os seus comentários! Envie este artigo, divulgue este link na sua rede social...


Tags: VBA, Tips, API, DLL, kernel32.dll, GetComputerName, Get, Computer, Name, 


VBA Tips - GetUser - Saiba o nome do usuários do Windows





Saiba o nome do usuário que está usando a sua aplicação.

Podemos usar essa funcionalidade para uma conexão automática, ou solicitação de identificação para acesso. Inclui API.


  Private Declare Function GetUserName Lib "advapi32.dll" Alias _      "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long        Function GetUser() As String              Dim UserName As String ' receives name of the user                Dim slength As Long ' length of the string            Dim RetVal As Long ' return value              UserName = Space(255) ' room for 255 characters              slength = 255 ' initialize the size of the string              RetVal = GetUserName(UserName, slength) ' slength is now the length of the returned string              UserName = Left(UserName, slength - 1) ' extract the returned info from the buffer                User = UserName            End Function



Deixe os seus comentários! Envie este artigo, divulgue este link na sua rede social...


Tags: VBA, API, DLL, api32.dll,




VBA Tips - Demonstrar o tempo em Milisegundos - How to Get Time in Milliseconds using VBA


Saber expressar o tempo em milisegundos pode ser importante em qualquer  aplicação VBA. Como fazê-lo?

Private Type SYSTEMTIME
wYear As Integer
wMonth As Integer
wDayOfWeek As Integer
wDay As Integer
wHour As Integer
wMinute As Integer
wSecond As Integer
wMilliseconds As Integer
End Type

Private Declare Sub GetSystemTime Lib "kernel32" _
(lpSystemTime As SYSTEMTIME)

Public Function TimeToMillisecond() As String
Dim tSystem As SYSTEMTIME
Dim sRet
On Error Resume Next
GetSystemTime tSystem
sRet = Hour(Now) & ":" & Minute(Now) & ":" & Second(Now) & _
":" & tSystem.wMilliseconds
TimeToMillisecond = sRet
End Function

Tags: Tips, milisegundos, miliseconds, API, LIB, kernel32, DLL, time, VBA, 

VBA Excel - Colocando um Ícone personalizado no Excel - Change Excel Icon


Sim, colocar um ícone que identifique sua aplicação pode dar uma visão mais profissional a ela. Existem usuários mais, digamos, caprichosos que gostam e se apegam a estes detalhes. Por isso precisamos desenvolver uma visão vendedora dos nossos produtos, melhorar o modo como tratamos os nossos softwares pode implicar em distribuirmos mais cópias de uma aplicação e até mesmo massificá-la num departamento ou empresa. Sim, é apenas um detalhe, mas pode inspirá-lo a alterar outros aspectos das suas aplicações.

Há alguns anos construí uma aplicação que interagia com diversos Workbooks diferentes: Ao passo que escolhia os diferentes relatórios na interface principal, fazia com que as sub-interfaces como que se dissolvessem enquanto um processo contrário reconstruía a interface escolhida. 

Recurso simples? Sim.

O acesso era mais demorado? Sim, mas o usuário gostou muito

Talvez porque fosse de uma agência de propaganda. Enfim, alguns toques de requinte podem abrir as portas para a sua aplicação ser aceita, distribuida e comentada. Seguem códigos:

Open an Excel workbook
Select Tools/Macro/Visual Basic Editor
In the VBE window, select View/Project Explorer
Select the 'ThisWorkbook' Module, copy and paste the code for it from above
Select Insert/Module, copy and paste the code for module1 into this module.
Now select File/Close and Return To Microsoft Excel
Save your work and close the workbook.

O ícone pode ser mudado a qualquer momento:
Option Explicit 
Private Sub Workbook_Open() 
    Application.Caption = " My Personalized Workbook" 
    ChangeApplicationIcon 
End Sub 

Código par o módulo
Option Explicit 
Declare Function GetActiveWindow32 Lib "USER32" Alias _ 
"GetActiveWindow" () As Integer 
Declare Function SendMessage32 Lib "USER32" Alias _ 
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _ 
ByVal wParam As Long, ByVal lParam As Long) As Long 
Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias _ 
"ExtractIconA" (ByVal hInst As Long, _ 
ByVal lpszExeFileName As String, _ 
ByVal nIconIndex As Long) As Long 
Sub ChangeApplicationIcon() 
     
    Dim Icon& 
     
     '*****Change Icon To Suit*******
    Const NewIcon$ = "Notepad.exe" 
     '*****************************
     
    Icon = ExtractIcon32(0, NewIcon, 0) 
    SendMessage32 GetActiveWindow32(), & H80, 1, Icon '< 1 = big Icon
    SendMessage32 GetActiveWindow32(), & H80, 0, Icon '< 0 = small Icon
     
End Sub 


Reference: Walk

Tags: VBA, Excel, Icon, ícone, image, API, DLL, Shell32.dll, J Walk

VBA Tips - Determina o tipo de conexão ativa - Determine Network Connection Type


A cada dia que passa é mais freqüente o uso de dados online oriundos de servidores na Web. Estes são automaticamente transformados em informações ao atualizarem os nossos Dashboards e Scorecards instantâneamente.


Para garantirmos que tais dados receberão as atualizações corretas no tempo apropriado é importante checarmos a conexão das nossas máquinas constantemente. A API InternetGetConnectedState declarada no wininet.dll retorna o estado da conexão do sistema local. A API é simples de usar, e retorna TRUE se houver uma conexão com a Internet.
As funções abaixo são muito úteis para garantir a validade de processos com este perfil:

IsNetConnectViaLAN

IsNetConnectViaModem

IsNetConnectViaProxy

IsNetConnectOnline

IsNetRASInstalled

GetNetConnectString


Inline image 2

Divirta-se com o código abaixo, colando-o inteiramente num novo módulo da sua aplicação.


Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/ Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
'               applications, but you may not reproduce
'               or publish this code on any web site,
'               online service, or distribute as source
'               on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Declare Function InternetGetConnectedState Lib "wininet" _
  (ByRef dwflags As Long, _
   ByVal dwReserved As Long) As Long

'Local system uses a modem to connect to the Internet.
Private Const INTERNET_CONNECTION_MODEM As Long = &H1

'Local system uses a LAN to connect to the Internet.
Private Const INTERNET_CONNECTION_LAN As Long = &H2

'Local system uses a proxy server to connect to the Internet.
Private Const INTERNET_CONNECTION_PROXY As Long = &H4

'No longer used.
Private Const INTERNET_CONNECTION_MODEM_BUSY As Long = &H8

Private Const INTERNET_RAS_INSTALLED As Long = &H10
Private Const INTERNET_CONNECTION_OFFLINE As Long = &H20
Private Const INTERNET_CONNECTION_CONFIGURED As Long = &H40

Private Sub Command1_Click()
   Let Text1.Text = IsNetConnectViaLAN()
   Let Text2.Text = IsNetConnectViaModem()
   Let Text3.Text = IsNetConnectViaProxy()
   Let Text4.Text = IsNetConnectOnline()
   Let Text5.Text = IsNetRASInstalled()
   Let Text6.Text = GetNetConnectString()
End Sub

Function IsNetConnectViaLAN() As Boolean
   Dim dwflags As Long
   
  'pass an empty variable into which the API will
  'return the flags associated with the connection
   Call InternetGetConnectedState(dwflags, 0&)

  'return True if the flags indicate a LAN connection
   IsNetConnectViaLAN = dwflags And INTERNET_CONNECTION_LAN
End Function

Function IsNetConnectViaModem() As Boolean
   Dim dwflags As Long
   
  'pass an empty variable into which the API will
  'return the flags associated with the connection
   Call InternetGetConnectedState(dwflags, 0&)

  'return True if the flags indicate a modem connection
   Let IsNetConnectViaModem = dwflags And INTERNET_CONNECTION_MODEM
End Function

Function IsNetConnectViaProxy() As Boolean

   Dim dwflags As Long
   
  'pass an empty variable into which the API will
  'return the flags associated with the connection
   Call InternetGetConnectedState(dwflags, 0&)

  'return True if the flags indicate a proxy connection
   Let IsNetConnectViaProxy = dwflags And INTERNET_CONNECTION_PROXY
End Function

Function IsNetConnectOnline() As Boolean
  'no flags needed here - the API returns True
  'if there is a connection of any type
   Let IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
End Function

Function IsNetRASInstalled() As Boolean
   Dim dwflags As Long
   
  'pass an empty variable into which the API will
  'return the flags associated with the connection
   Call InternetGetConnectedState(dwflags, 0&)

  'return True if the flags include RAS installed
   Let IsNetRASInstalled = dwflags And INTERNET_RAS_INSTALLED
End Function

Function GetNetConnectString() As String

   Dim dwflags As Long
   Dim msg As String

  'build a string for display
   If InternetGetConnectedState(dwflags, 0&) Then
     
      If dwflags And INTERNET_CONNECTION_CONFIGURED Then
         Let msg = msg & "Você tem uma conexão de rede configurada." & vbCrLf
      End If

      If dwflags And INTERNET_CONNECTION_LAN Then
         Let msg = msg & "O sistemas local conecta-se a Internet via LAN"
      End If
      
      If dwflags And INTERNET_CONNECTION_PROXY Then
         Let msg = msg & ", e usuários no Servidor de Proxy. "
      Else
         Let msg = msg & "."
      End If
      
      If dwflags And INTERNET_CONNECTION_MODEM Then
         Let msg = msg & "O sistema local usa um modem para conectar-se a Internet. "
      End If
      
      If dwflags And INTERNET_CONNECTION_OFFLINE Then
         Let msg = msg & "A conexão está offline. "
      End If
      
      If dwflags And INTERNET_CONNECTION_MODEM_BUSY Then
         Let msg = msg & "O sistema de Modem local está ocupado com uma conexão non-Internet. "
      End If
      
      If dwflags And INTERNET_RAS_INSTALLED Then
         Let msg = msg & "Serviço de Acesso Remoto instalado neste sistema."
      End If
      
   Else
    
      Let msg = "Não conectado a Internet agora."
      
   End If
   
   Let GetNetConnectString = msg
End Function


Tags: VBA, Tips, Network, Connection, Type, code, network, DLL, wininet.dll

VBA Excel - Mudando o ícone padrão de uma planilha.

Inline image 1


Hello Folks!

Imagine em certo momento do seu dia-a-dia, onde diversas planilhas estão abertas simultaneamente. Isso é raro? Certamente Não. Uma das coisas mais úteis seria identificarmos rapidamente a planilha (ou aplicação MS Excel) que desejamos trabalhar naquele momento.

Quando olhamos para a nossa barra de tarefas do Windows observamos inúmeras planilhas abertas ou ainda pior, olhamos aquele ícone com todos as planilhas agrupadas.

E se...e somente se, pudéssemos atribuir um ícone diferente para cada aplicação MS Excel que estivéssemos usando? Imagine identificarmos a nossa aplicação rapidamente através do seu ícone, seria muito bom! Além disso destacaríamos a nossa aplicação de outras que estivessem rodando nas máquinas dos nossos Clientes.

Mas é possível alterar o ícone de uma planilha específica, ou de várias, que estão rodando em nossa máquina? Tá bom, chega de tortura, segue como é que se faz:

Ao abrir a planilha, solicite que uma das primeiras coisas a serem executadas, seja a nossa SUB ChangeAppIcon:

Private Sub Workbook_Open()
    ' Author:                     Date:                       Contact:                            URL:
    ' André Bernardes      02/03/2011 09:40    bernardess@gmail.com     http://al-bernardes.sites.uol.com.br/
    ' Application: ***
    ' Ao abrir o formulário.
    ' Listening: - .
    ' Re-escrito/Atualizado em: .
    
    Let Application.ScreenUpdating = False
    Let Application.Caption = ".: Minha Aplicação"
    Let Application.StatusBar = "A&A - In Any Place"

    ' Abre um formulário.
    frmSplash.Show

    Call ChangeAppIcon
    Let Application.ScreenUpdating = True
End Sub

Em seguida crie um módulo com o nome de mdl_Functions_PutIcon e cole o código abaixo nele:

Option Explicit

Declare Function GetActiveWindow32 Lib "USER32" Alias "GetActiveWindow" () As Integer

Declare Function SendMessage32 Lib "USER32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long

Sub ChangeAppIcon()

    ' Author:                     Date:                       Contact:                            URL:
    ' André Bernardes      02/03/2011 08:14    bernardess@gmail.com     http://al-bernardes.sites.uol.com.br/
    ' Application: 
    ' Modification of code from Excel Experts E-Letter Archives.
    ' Original code By Jim Rech can be found by following this
    ' Listening: - .
    ' Re-escrito/Atualizado em: .
    Dim Icon&

    ' Change Icon To Suit

    Const NewIcon$ = "C:\Bernardes\Application.ico" 

    Let Icon = ExtractIcon32(0, NewIcon, 0)

    SendMessage32 GetActiveWindow32(), &H80, 1, Icon '< 1 = big Icon

    SendMessage32 GetActiveWindow32(), &H80, 0, Icon '< 0 = small Icon
End Sub

Pronto! Agora você tem a solução para alterar o ícone das suas aplicações desenvolvidas com o MS Excel.

Esse ícone pode ser utilizado como indicador e ser alterado de acordo com um parâmetro, é só utilizar a sua imaginação, de acordo com a sua necessidade.

Outro aspecto interessante é o de que você também pode utilizar um ícone de arquivo executável, como por exemplo o Notepad.exe. Basta que coloque o caminho onde ele está no ambiente do Windows que o seu ícone será mostrado.

Tags: VBA, MS, Microsoft, MS Office, Automation, Automação, Aplicação, Application, Icon, ícone, image, change, DLL, API, SendMessage, LIB, USER32.DLLSHELL32.DLL




diHITT - Notícias