Página 1 de 1

PROBLEMA DE COMPATIBILIDADE VBA 64 E 32 [VB / VBA]

Enviado: Qui Jan 02, 2014 1:12 pm
por lucaslc7
:oops: tenho dois computadores e ultilizo um codico vba para facilitar a vida, fiz o codigo com api de 32bits ai nao funcionou no 64 bits arrumei inserindo ptrsafe
para 32

Código: Selecionar todos

  
Option Explicit
Private Declare  Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare  Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare  Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare  Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
 
para 64

Código: Selecionar todos

Option Explicit
Private Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare  PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long

ai nao funciona no 32, assim nao da ne, nao posso ficar corrigindo isso sempre.
espero a ajuda obrigado

Re: PROBLEMA DE COMPATIBILIDADE VBA 64 E 32 [VB / VBA]

Enviado: Qui Jan 02, 2014 9:01 pm
por Mikel Silveira Fraga
Lucas, boa noite e seja bem vindo ao fórum.

Sobre este teu erro, dê uma olhada no link abaixo:
Compatibilidade de Chamadas API no VBA

Abraços.

Re: PROBLEMA DE COMPATIBILIDADE VBA 64 E 32 [VB / VBA]

Enviado: Ter Abr 16, 2019 4:18 pm
por Marcosgn27
Acrescente esta condição

#If Win32 Then

#Else

#End if