AMdeAlcantara escreveu: ↑Ter Abr 25, 2017 4:14 pm
Caros
Tenho uma planilha desenvolvida em Excel 2010 32 bits, na qual utilizo os seguintes módulos:
Módulo 1
#If VBA7 Then 'Declaração de API´s para versões do MS Office 2010+.
#If Win64 Then 'Declaração para as versões 64 bits.
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As LongLong, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongLong) As _
LongLong
#Else 'Declaração para as versões 32 bits.
Public Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As _
LongPtr
#End If
#ElseIf VBA6 Then 'Declaração de API´s para versões do MS Office 2007-.
Public Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As _
Long
#End If
Módulo 2
Option Explicit
'OCULTA OS BOTÕES MINIMIZAR / MAXIMIZAR E FECHAR DA BARRA DO EXCEL
'Sem as declarações abaixo as macros para retirar e repor os botões não funcionará
#If VBA7 Then 'Declaração de API´s para versões do MS Office 2010+.
Declare PtrSafe Function FindWindow32 Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Declare PtrSafe Function GetWindowLong32 Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer) As Long
Declare PtrSafe Function SetWindowLong32 Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer, _
ByVal dwNewLong As Long) As Long
#Else 'Declaração para as versões 32 bits.
Declare Function FindWindow32 Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As Any, ByVal lpWindowName As Any) As Integer
Declare Function GetWindowLong32 Lib "user32" Alias "GetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer) As Long
Declare Function SetWindowLong32 Lib "user32" Alias "SetWindowLongA" _
(ByVal hWnd As Integer, ByVal nIndex As Integer, _
ByVal dwNewLong As Long) As Long
#End If
Global Const GWL_STYLE = (-16)
Global Const WS_SYSMENU = &H80000
Sub RetiraXdaBarra()
Application.ScreenUpdating = False
Dim WindowStyle As Long
Dim hWnd As Integer
Dim WindowName As String
Dim Result As Variant
WindowName = Application.Caption
hWnd = FindWindow32(0&, ByVal WindowName)
WindowStyle = GetWindowLong32(hWnd, GWL_STYLE)
WindowStyle = WindowStyle And (Not WS_SYSMENU)
Result = SetWindowLong32(hWnd, GWL_STYLE, WindowStyle)
'Força a barra de títulos a se atualizar, Ocultando os Botões
Application.Caption = ""
ActiveWindow.Caption = ""
End Sub
EstaPasta_de_Trabalho
Public Sub Workbook_Open()
'Oculta todas as guias de menu
Application.ExecuteExcel4Macro "SHOW.TOOLBAR(""Ribbon"",False)"
'Ocultar barra de fórmulas
Application.DisplayFormulaBar = False
'Ocultar barra de status, disposta ao final da planilha
Application.DisplayStatusBar = False
With ActiveWindow
'Ocultar barra horizontal
.DisplayHorizontalScrollBar = True
'Ocultar barra vertical
.DisplayVerticalScrollBar = True
'Ocultar guias das planilhas
.DisplayWorkbookTabs = False
'Oculta os títulos de linha e coluna
.DisplayHeadings = False
'Oculta valores zero na planilha
.DisplayZeros = True
'Oculta as linhas de grade da planilha
.DisplayGridlines = False
Application.ScreenUpdating = False
Call RetiraXdaBarra
Application.ScreenUpdating = True
End With
End Sub
Pois bem, quando a planilha é aberta em qualquer versão com 32 bits (mesmo a 2016) funciona redondinho, sem qualquer problema, mas quando se tenta abrir na versão 64 bits (2010+) relata erro oculto no
Módulo 2, ou seja, parece que o código do
Módulo 1 não está cumprindo a sua função.
Está faltando algo?
Agradeço se receber sugestões de correção.