You are on page 1of 13

1 - Crie um m�dulo de classe

Crie um m�dulo de classe no seu projeto VBA e cole o c�digo abaixo.

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 GetSystemMenu Lib "user32" (ByVal hWnd As Long,
ByVal bRevert As Long) As Long
Private Declare PtrSafe Function DeleteMenu Lib "user32" (ByVal hMenu As Long,
ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hWnd As Long, ByVal
nCmdShow As Long) As Long
Private Declare PtrSafe Function EnableWindow Lib "user32" (ByVal hWnd As Long,
ByVal fEnable As Long) As Long
Private Declare PtrSafe Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As
Long
Private Declare PtrSafe Function SetFocus Lib "user32" (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA"
(ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As
Long
Private Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As
Long) As Long

Private Const GWL_STYLE As Long = (-16)


Private Const GWL_EXSTYLE As Long = (-20)
Private Const WS_CAPTION As Long = &HC00000
Private Const WS_SYSMENU As Long = &H80000
Private Const WS_THICKFRAME As Long = &H40000
Private Const WS_MINIMIZEBOX As Long = &H20000
Private Const WS_MAXIMIZEBOX As Long = &H10000
Private Const WS_POPUP As Long = &H80000000
Private Const WS_VISIBLE As Long = &H10000000

Private Const WS_EX_DLGMODALFRAME As Long = &H1


Private Const WS_EX_APPWINDOW As Long = &H40000
Private Const WS_EX_TOOLWINDOW As Long = &H80

Private Const SC_CLOSE As Long = &HF060

Private Const SW_HIDE As Long = 0


Private Const SW_SHOW As Long = 5
Private Const SW_MAXIMIZE As Long = 3

Private Const WM_SETICON = &H80

Dim hWndForm As Long, mbSizeable As Boolean, mbCaption As Boolean, mbIcon As


Boolean, miModal As Integer
'Dim mbMaximize As Boolean
Dim mbMinimize As Boolean, mbSysMenu As Boolean, mbCloseBtn As Boolean
Dim mbAppWindow As Boolean, mbToolWindow As Boolean, msIconPath As String
Dim moForm As Object
Public Property Let Modal(bModal As Boolean)
miModal = Abs(CInt(Not bModal))

'Make the form modal or modeless by enabling/disabling Excel itself


EnableWindow FindWindow("XLMAIN", Application.Caption), miModal
End Property

Public Property Get Modal() As Boolean


Modal = (miModal <> 1)
End Property

Public Property Set Form(oForm As Object)

If Val(Application.Version) < 9 Then


hWndForm = FindWindow("ThunderXFrame", oForm.Caption) 'XL97
Else
hWndForm = FindWindow("ThunderDFrame", oForm.Caption) 'XL2000
End If

Set moForm = oForm

AtualizarEstiloForm

Dim strIconPath As String


Dim lngIcon As Long
Dim lnghWnd As Long
strIconPath = ThisWorkbook.Path & "\exemplo.ico" 'Insira aqui o caminho
completo do �cone - no formato .ICO resolu��o 32x32'
lngIcon = ExtractIcon(0, strIconPath, 0)
lnghWnd = FindWindow("ThunderDFrame", oForm.Caption)
SendMessage lnghWnd, WM_SETICON, True, lngIcon
SendMessage lnghWnd, WM_SETICON, False, lngIcon

End Property

Private Sub AtualizarEstiloForm()

Dim iStyle As Long, hMenu As Long, hID As Long, iItems As Integer

If hWndForm = 0 Then Exit Sub

iStyle = GetWindowLong(hWndForm, GWL_STYLE)

iStyle = iStyle Or WS_CAPTION


iStyle = iStyle Or WS_SYSMENU
'iStyle = iStyle Or WS_THICKFRAME
iStyle = iStyle Or WS_MINIMIZEBOX
iStyle = iStyle Or WS_MAXIMIZEBOX
iStyle = iStyle And Not WS_VISIBLE And Not WS_POPUP

SetWindowLong hWndForm, GWL_STYLE, iStyle

iStyle = GetWindowLong(hWndForm, GWL_EXSTYLE)

iStyle = iStyle And Not WS_EX_DLGMODALFRAME


iStyle = iStyle Or WS_EX_APPWINDOW

SetWindowLong hWndForm, GWL_EXSTYLE, iStyle


hMenu = GetSystemMenu(hWndForm, 0)

ShowWindow hWndForm, SW_SHOW 'Substitua SW_SHOW por SW_MAXIMIZE, para ter um


tela maximizada no in�cio
DrawMenuBar hWndForm
SetFocus hWndForm

End Sub

-----------------------------------------------------------------------------------
----
2 - Crie um m�dulo (normal)
Crie um m�dulo normal no seu projeto e insira o c�digo abaixo.

Option Explicit

Private Declare PtrSafe Function GetForegroundWindow Lib "user32" () As Long

Declare PtrSafe Function SetWindowLong Lib "user32.dll" Alias "SetWindowLongA" ( _


ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" ( _


ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Declare PtrSafe Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _


(ByVal Destination As Long, ByVal Source As Long, ByVal Length As Long)

Declare PtrSafe Function SetWindowsHookEx Lib _


"user32" Alias "SetWindowsHookExA" (ByVal idHook As Long, ByVal lpfn As Long, _
ByVal hmod As Long, ByVal dwThreadId As Long) As Long

Declare PtrSafe Function CallNextHookEx Lib "user32" (ByVal hHook As Long, _


ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long

Declare PtrSafe Function UnhookWindowsHookEx Lib "user32" (ByVal hHook As Long) As


Long

Type POINTAPI
x As Long
Y As Long
End Type

Type MSLLHOOKSTRUCT
pt As POINTAPI
mouseData As Long
flags As Long
time As Long
dwExtraInfo As Long
End Type

Const HC_ACTION = 0
Const WH_MOUSE_LL = 14
Const WM_MOUSEWHEEL = &H20A

Dim hhkLowLevelMouse, lngInitialColor As Long


Dim udtlParamStuct As MSLLHOOKSTRUCT
Public intTopIndex As Integer
Function GetHookStruct(ByVal lParam As Long) As MSLLHOOKSTRUCT

CopyMemory VarPtr(udtlParamStuct), lParam, LenB(udtlParamStuct)

GetHookStruct = udtlParamStuct

End Function

Function LowLevelMouseProc _
(ByVal nCode As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

On Error Resume Next

If (nCode = HC_ACTION) Then

If wParam = WM_MOUSEWHEEL Then

LowLevelMouseProc = True

'ATEN��O: Troque o nome do seu Userform


With UserForm1

'ROLAR PARA CIMA


If GetHookStruct(lParam).mouseData > 0 Then
.ScrollTop = intTopIndex - 10
intTopIndex = .ScrollTop
Else
'ROLAR PARA BAIXO
.ScrollTop = intTopIndex + 10
intTopIndex = .ScrollTop
End If

End With

End If

Exit Function

End If

UnhookWindowsHookEx hhkLowLevelMouse
LowLevelMouseProc = CallNextHookEx(0, nCode, wParam, ByVal lParam)
End Function

Sub Hook_Mouse()
If hhkLowLevelMouse <> 0 Then
UnhookWindowsHookEx hhkLowLevelMouse
End If

hhkLowLevelMouse = SetWindowsHookEx _
(WH_MOUSE_LL, AddressOf LowLevelMouseProc, Application.Hinstance, 0)

End Sub

Sub UnHook_Mouse()

If hhkLowLevelMouse <> 0 Then UnhookWindowsHookEx hhkLowLevelMouse

End Sub
-----------------------------------------------------------------------
3 - Crie um formul�rio
Pronto, agora em todos os formul�rios que voc� criar no seu projeto, insira o
c�digo abaixo. Cada um no seu respectivo procedimento.

'Essa parte vai no topo do seu c�digo, fora dos subs e procedimentos'
Dim nAtualizaForm As New Classe1
Dim T
Dim frmUserWidth As Double
Dim frmUserWidthRatio As Double
Dim frmUserHeight As Double
Dim frmUserHeightRatio As Double
Dim r As Integer
Dim c As Integer
Dim ctl As Control

'No procedimento Activate do Userform'


Private Sub UserForm_Activate()
Set nAtualizaForm.Form = Me
End Sub

'No evento INITIALIZE do Userform'


Private Sub UserForm_Initialize()
Dim hWnd As Long

'Vai para o topo do formul�rio


ScrollTop = 0

'Define os bot�es minimizar e maximizar do form


hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, &H20000 Or &H10000 Or &H84C80080

frmUserWidth = Me.InsideWidth
frmUserHeight = Me.InsideHeight
end sub

'Essa parte no evento Resize'


Private Sub UserForm_Resize()

If Me.InsideHeight < 1 Then Exit Sub

frmUserWidthRatio = Me.InsideWidth / frmUserWidth


frmUserHeightRatio = Me.InsideHeight / frmUserHeight

' Eliminate this section to prevent resizing of controls on form.


' Stick any control on the form at any location.
For Each ctl In Me.Controls
ctl.Width = frmUserWidthRatio * ctl.Width
ctl.Left = frmUserWidthRatio * ctl.Left
ctl.Height = frmUserHeightRatio * ctl.Height
ctl.Top = frmUserHeightRatio * ctl.Top
Next

frmUserWidth = Me.InsideWidth
frmUserHeight = Me.InsideHeight
End Sub

---------------------------------------------------------------------------
Tela de Login com Design Moderno em VBA'

'FERNANDO NEPOMUCENO - ORGANIC SHEETS


'CHAMADAS DE APIS RESPONS�VEIS POR MANIPULAR AS CARACTERISTICAS DO USERFORM
'PARA DEIXA-LO TRANSPARENTE E SEM BORDAS

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 DrawMenuBar Lib "user32" ( _


ByVal hWnd As Long) As Long

Private Declare Function SetLayeredWindowAttributes Lib "user32" ( _


ByVal hWnd As Long, _
ByVal crKey As Long, _
ByVal bAlpha As Byte, _
ByVal dwFlags As Long) As Long

'Constants for title bar


Private Const GWL_STYLE As Long = (-16) 'The offset of a window's style
Private Const GWL_EXSTYLE As Long = (-20) 'The offset of a window's extended
style
Private Const WS_CAPTION As Long = &HC00000 'Style to add a titlebar
Private Const WS_EX_DLGMODALFRAME As Long = &H1 'Controls if the window has
an icon

'Constants for transparency


Private Const WS_EX_LAYERED = &H80000
Private Const LWA_COLORKEY = &H1 'Chroma key for fading a certain color on
your Form
Private Const LWA_ALPHA = &H2 'Only needed if you want to fade the entire
userform
Private m_sngDownX As Single
Private m_sngDownY As Single

Private Sub lbl_dark_MouseDown(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)
'ESTA FUN��O PERMITE QUE EU ARRASTE O USERFORM PELO LABEL QUE REPRESENTA MEU
BACKGROUND - MODO DARK
If Button = 1 Then
m_sngDownX = X
m_sngDownY = Y
End If
End Sub

Private Sub lbl_dark_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)
'ESTA FUN��O MAPEIA MINHA COORDENADAS PARA QUE EU ARRASTE O USERFORM PELO LABEL QUE
REPRESENTA MEU BACKGROUND - MODO DARK
If Button And 1 Then
Me.Left = Me.Left + (X - m_sngDownX)
Me.Top = Me.Top + (Y - m_sngDownY)
End If
End Sub

Private Sub lbl_white_MouseDown(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)
'ESTA FUN��O PERMITE QUE EU ARRASTE O USERFORM PELO LABEL QUE REPRESENTA MEU
BACKGROUND
If Button = 1 Then
m_sngDownX = X
m_sngDownY = Y
End If
End Sub

Private Sub lbl_white_MouseMove(ByVal Button As Integer, ByVal Shift As Integer,


ByVal X As Single, ByVal Y As Single)
'ESTA FUN��O MAPEIA MINHA COORDENADAS PARA QUE EU ARRASTE O USERFORM PELO LABEL QUE
REPRESENTA MEU BACKGROUND
If Button And 1 Then
Me.Left = Me.Left + (X - m_sngDownX)
Me.Top = Me.Top + (Y - m_sngDownY)
End If
End Sub

Private Sub UserForm_Activate()


'EST� FUN��O APLICA AS TRANSPARENCIAS E OCULTA AS BORDAS QUANDO O USERFORM ESTIVER
ATIVO

HideTitleBarAndBorder Me 'hide the titlebar and border


MakeUserFormTransparent Me 'make certain color transparent
End Sub

Sub MakeUserFormTransparent(frm As Object, Optional Color As Variant)

'FUN��O QUE DEFINE A TRANSPARENCIA DO USERFORM

Dim formhandle As Long


Dim bytOpacity As Byte

formhandle = FindWindow(vbNullString, Me.Caption)


If IsMissing(Color) Then Color = 1257038 'default to vbwhite
bytOpacity = 100 ' variable keeping opacity setting

SetWindowLong formhandle, GWL_EXSTYLE, GetWindowLong(formhandle, GWL_EXSTYLE)


Or WS_EX_LAYERED
'The following line makes only a certain color transparent so the
' background of the form and any object whose BackColor you've set to match
' vbColor (default vbWhite) will be transparent.
Me.BackColor = Color
SetLayeredWindowAttributes formhandle, Color, bytOpacity, LWA_COLORKEY
End Sub

Sub HideTitleBarAndBorder(frm As Object)

'FUN��O QUE OCULTA AS BORDAS DO USERFORM

'Hide title bar and border around userform


Dim lngWindow As Long
Dim lFrmHdl As Long
lFrmHdl = FindWindow(vbNullString, frm.Caption)
'Build window and set window until you remove the caption, title bar and frame
around the window
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)
SetWindowLong lFrmHdl, GWL_STYLE, lngWindow
lngWindow = GetWindowLong(lFrmHdl, GWL_EXSTYLE)
lngWindow = lngWindow And Not WS_EX_DLGMODALFRAME
SetWindowLong lFrmHdl, GWL_EXSTYLE, lngWindow
DrawMenuBar lFrmHdl
End Sub

Private Sub bt_fechar_dark_Click()


'BOT�O DE FECHAMENTO DA JANELA - MODO DARK
Unload Me
Application.Visible = True
End Sub

Private Sub bt_fechar_white_Click()


'BOT�O DE FECHAMENTO DA JANELA
Unload Me
Application.Visible = True

End Sub

Private Sub bt_go_dark_Click()

'AQUI VOC� PODE FAZER A SUA VALIDA��O DO LOGIN - MODO DARK

If Me.txt_login = "admin" And Me.txt_senha = "admin" Then


MsgBox "Login realizado com sucesso!", vbInformation, "Organic Sheets"
Else
MsgBox "Login N�O realizado, verifique a senha!", vbCritical, "Organic
Sheets"
End If

End Sub

Private Sub bt_go_white_Click()

'AQUI VOC� PODE FAZER A SUA VALIDA��O DO LOGIN

If Me.txt_login = "admin" And Me.txt_senha = "admin" Then


MsgBox "Login realizado com sucesso!", vbInformation, "Organic Sheets"
Else
MsgBox "Login N�O realizado, verifique a senha!", vbCritical, "Organic
Sheets"
End If

End Sub
Private Sub bt_linkedin_Click()
'APROVEITA E ME SEGUE L� NO LINKEDIN - OBRIGADO
ActiveWorkbook.FollowHyperlink Address:="https://www.linkedin.com/in/fernando-
nepomuceno-6a740599"
End Sub

Private Sub bt_modo_dark_Click()


'MUDA PARA O MODO DARK E ARMAZENA A ESCOLHA DO USU�RIO
Call modo_dark
plan_aux.Range("A2") = "s"
End Sub

Private Sub bt_modo_white_Click()


'MUDA PARA O MODO WHITE E ARMAZENA A ESCOLHA DO USU�RIO
Call modo_white
plan_aux.Range("A2") = "n"
End Sub

Private Sub bt_ocultar_senha_Click()

'MUDA A PROPRIEDADE DO TEXTBOX DE SENHA, TORNANDO A SENHA VIS�VEL

If Me.txt_senha.PasswordChar = "�" Then


Me.txt_senha.PasswordChar = ""
Else
Me.txt_senha.PasswordChar = "�"
End If

End Sub

Private Sub bt_youtube_Click()


'APROVEITA E SE INSCREVE L� NO CANAL DA ORGANICSHEETS - OBRIGADO
ActiveWorkbook.FollowHyperlink
Address:="https://www.youtube.com/channel/UCYvI3mWCvFqQXeFOJptIULw?
sub_confirmation=1"
End Sub

Private Sub lbl_cadastro_Click()


'AQUI VOC� PODE ESCREVER A L�GICA PARA ARMAZENAR NOVO USU�RIO
MsgBox "Cadastro realizado com sucesso!", vbInformation, "Organic Sheets"
End Sub

Private Sub UserForm_Initialize()


'NO MODO INITIALIZE O SISTEMA CONFERE QUAL A PREFERENCIA DO USU�RIO E ABRE NO MODO
ESCOLHIDO

If plan_aux.Range("A2").Text = "s" Then


Call modo_dark
Else
Call modo_white
End If

With Me.lbl_dark
.Left = Me.lbl_white.Left
.Top = Me.lbl_white.Top
End With
With Me.bt_go_dark
.Left = Me.bt_go_white.Left
.Top = Me.bt_go_white.Top
End With

End Sub

Private Sub webb_NavigateComplete2(ByVal pDisp As Object, URL As Variant)


'AP�S A APLICA��O DO MODO DARK O GIF FICA COM UMA BORDA BRANCA, ESSE M�TODO SERVER
PARA MUDAR A COR DESSA BORDA
If Me.lbl_dark.Visible = True Then
webb.Document.body.bgcolor = 1841452
End If

End Sub

Sub modo_dark()
'SUB PARA ATIVAR O MODO DARK, OCULTA TODOS OS ELEMENTOS DO MODO WHITE E CARREGA O
GIF DO MODO DARK

Dim gif As String

Me.lbl_dark.Visible = True
Me.bt_modo_dark.Visible = False
Me.lbl_white.Visible = False
Me.bt_modo_white.Visible = True
Me.bt_fechar_dark.Visible = True
Me.bt_fechar_white.Visible = False
Me.lbl_bem_vindo.ForeColor = RGB(254, 255, 255)
Me.lbl_orienta.ForeColor = RGB(254, 255, 255)
Me.lbl_cad.ForeColor = RGB(254, 255, 255)

Me.bt_go_white.Visible = False
Me.bt_go_dark.Visible = True

gif = ThisWorkbook.Path & "\images\Security-dark.gif"


webb.Navigate "about:<html><body scroll='no'><img src='" & gif &
"'style='display: block;margin-left: 0px; margin-right: 0px;;height: 100%;width:
100%;'></img></body></html>"

End Sub

Sub modo_white()
'SUB PARA ATIVAR O MODO WHITE, OCULTA TODOS OS ELEMENTOS DO MODO DARK E CARREGA O
GIF DO MODO WHITE
Dim gif As String

Me.lbl_dark.Visible = False
Me.bt_modo_dark.Visible = True
Me.lbl_white.Visible = True
Me.bt_modo_white.Visible = False
Me.bt_fechar_dark.Visible = False
Me.bt_fechar_white.Visible = True
Me.lbl_bem_vindo.ForeColor = &H80000012
Me.lbl_orienta.ForeColor = &H404040
Me.lbl_cad.ForeColor = &H404040

Me.bt_go_white.Visible = True
Me.bt_go_dark.Visible = False

gif = ThisWorkbook.Path & "\images\Security.gif"


webb.Navigate "about:<html><body scroll='no'><img src='" & gif &
"'style='display: block;margin-left: 0px; margin-right: 0px;;height: 100%;width:
100%;'></img></body></html>"

End Sub
---------------------------------------------------------------------
Sub conexao()

Dim BD As New ADODB.Connection


Dim consulta As New ADODB.Recordset
Dim pasta As String, cs As String

pasta = ThisWorkbook.Path
cs = "Provider=Micosoft.ACE.OLEDB.12.0;" _
& "Data Source=C:\myFolder\myAccessFile.accdb;" _
& "Persist Security Info=False;"

MsgBox cs

End Sub
------------------------------------------------------------------------

C�digo VBA 1: salvar e fechar automaticamente um arquivo do Excel ap�s um certo


tempo de inatividade

Dim xTime As String


Dim xWB As Workbook

Private Sub Workbook_Open()


'Updated by Extendoffice 2019/1/20
On Error Resume Next
xTime = Application.InputBox("Please specify the idle time:", "KuTool For
Excel", "00:00:20", , , , , 2)
Set xWB = ActiveWorkbook
If xTime = "" Then Exit Sub
Reset
End Sub
Private Sub Workbook_SheetActivate(ByVal Sh As Object)
On Error Resume Next
If xTime = "" Then Exit Sub
Reset
End Sub

Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)


On Error Resume Next
If xTime = "" Then Exit Sub
Reset
End Sub

Sub Reset()
Static xCloseTime
If xCloseTime <> 0 Then
ActiveWorkbook.Application.OnTime xCloseTime, "SaveWork1", , False
End If
xCloseTime = Now + TimeValue(xTime)
ActiveWorkbook.Application.OnTime xCloseTime, "SaveWork1", , True
End Sub

salvar e fechar automaticamente um arquivo do Excel ap�s um certo tempo de


inatividade

Sub SaveWork1()
'Updated by Extendoffice 2019/1/20
Application.DisplayAlerts = False
ActiveWorkbook.Save
ActiveWorkbook.Close

Application.DisplayAlerts = True
End Sub
-----------------------------------------------------------------------------------
------
excluir

Pravate Sub STEXCIWAL Clack()


im nome Rs Serioo
Math Norkabeesa ("Planihel") .Range ("B:B")
Sert c = .Tindiextncme.Vaiue, 1ooratimalmsde)
T Nov c 1s Noching Then
nome = MagBox("Dese�a excluir este cadastro?", velesNo, "Conf�rmar�)
Mog�cx Fcadastro excisido.�
TMN
Meg�os "Cadastro n�o exciuidor
En Wice
txtacne.Text = "5
atendere�o.Texe & ""
Taraameso Text = n

-----------------------------------------------------------------------------------
---------------------------

For ArrIndx = 1 To grvNdados.RecordCount



� If Not dic.Exists(LCase(grvNdados!tipo)) Then
� � � dic.Add LCase(grvNdados!tipo), Nothing
� � � � If grvNdados!tipo = "Despesas" Then
� � � � � � Set nodxR1 = UcaixaArvore.tvFicha.Nodes.Add("Ficha", tvwChild,
grvNdados!tipo, _
� � � � � � grvNdados!tipo, 3)
� � � � � � nodxR1.Expanded = True
� � � � Else
� � � � � � Set nodxR1 = UcaixaArvore.tvFicha.Nodes.Add("Ficha", tvwChild,
grvNdados!tipo, _
� � � � � � grvNdados!tipo, 2)
� � � � � �
� � � � End If
� End If
#� If Not dic.Exists(LCase(grvNdados!Conta)) Then
� � � dic.Add LCase(grvNdados!Conta), Nothing
� � � � If grvNdados!tipo = "Despesas" Then
� � � � � � Set nodxR2 = UcaixaArvore.tvFicha.Nodes.Add(nodxR1, tvwChild, _
� � � � � � grvNdados!Conta, grvNdados!Conta, 3)
� � � � Else
� � � � � � Set nodxR2 = UcaixaArvore.tvFicha.Nodes.Add(nodxR1, tvwChild, _
� � � � � � grvNdados!Conta, grvNdados!Conta, 2)
� � � � End If
� � � �
� End If

� If Not dic.Exists(LCase(grvNdados!Grupo)) Then
� � � dic.Add LCase(grvNdados!Grupo), Nothing
� � � � If grvNdados!tipo = "Despesas" Then
� � � � � � Set nodxR3 = UcaixaArvore.tvFicha.Nodes.Add(nodxR2, tvwChild, _
� � � � � � grvNdados!Grupo, grvNdados!Grupo, 3)
� � � � Else
� � � � � � Set nodxR3 = UcaixaArvore.tvFicha.Nodes.Add(nodxR2, tvwChild, _
� � � � � � grvNdados!Grupo, grvNdados!Grupo, 2)
� � � � End If

-----------------------------------------------------------------------------------
-------------------
Salva

if Nome.Value= "" or Oferta.Value= "" or D�zimo.Value = "" or Data.Value = ""


msgBox "preencha todos os campos", vbInformation
Exit Sub
End if

Range("A3").EntireRow.Insert
Range("B3").Value = Nome.Value
Range("C3").Value = Oferta.Value
Range("D3").Value = D�zimo.Value
Range("E3").Value = Data.Value

Nome.Text = ""
Oferta.Text = ""
D�zimo.Text = ""
Data.Text = ""
----------------------------------------------------------------------
hidetilebarandbordar me

You might also like