Bem, não sou usuário dos Mac's, talvez alguém que o seja possa contribuir com sua opinião.
Segue o link (tomara que não sumam com o artigo).
Vou guardar uma cópia em pdf no meu e-mail, caso o link esteja quebrado.
;-)
Eventualmente dicas sobre outros programas, Windows e hardware.
Sub ver()
Dim arquivo As String
arquivo = "c:\teste.xls"
Dim cnn As New ADODB.Connection
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;data source = " _
& arquivo & ";Extended Properties=Excel 8.0;"
On Error Resume Next
cnn.Execute "SELECT top 1 * from [planilha1$]"
If Err.Number = 0 Then
MsgBox "Planilha existe"
Else
MsgBox "Planilha não existe"
End If
cnn.Close
Set cnn = Nothing
End Sub
Sub carrega_listview2()
With Me.Listview2
.View = lvwReport
.GridLines = True
.FullRowSelect = True
.ListItems.Clear
.ColumnHeaders.Clear
End With
'Cabeçalho do ListView
With Me.Listview2.ColumnHeaders
.Add , , "N/Número", 1500, lvwcolumright
.Add , , "Cartório", 1300, lvwColumnLeft
.Add , , "Protocolo", 1300, lvwcolumright
.Add , , "Vencimento", 1300, lvwColumnLeft
.Add , , "Valor", 1000, lvwcolumright
End With
'Adicionar itens
rst.MoveFirst
Do Until rst.EOF
Set lstItem = Me.Listview2.ListItems.Add()
lstItem.Text = Format(rst!Nosso_Numero, "000000000000000")
lstItem.SubItems(1) = Format(rst!numero_tabe_protesto, "00")
lstItem.SubItems(2) = Format(rst!numero_protocolo, "0000000000")
lstItem.SubItems(3) = rst!data_venc
lstItem.SubItems(4) = Format(rst!vl_titulo / 100, "#0.00")
rst.MoveNext
Loop
rst.Close
End Sub
Option Explicit
Sub teste_box()
Dim variavel As Range
Set variavel = Application.InputBox(prompt:="Região a ser apagada:", _
Title:="Box do Excel", Type:=8)
variavel.ClearContents
End Sub
Public Declare Sub Sleep Lib "kernel32" Alias "Sleep" (ByVal dwMilliseconds As Long)
Public Sub Pausa(ByVal segundos As Single)
Call Sleep(Int(segundos * 1000#))
End Sub
'Para usar - exemplo:
'Call Closeprocess("Excel.exe")
================================
Option Explicit
Public Const TH32CS_SNAPPROCESS As Long = 2&
Public Const MAX_PATH As Long = 260
Public Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Public Const PROCESS_ALL_ACCESS As Long = &H1F0FFF
Public Declare Function CreateToolhelp32Snapshot Lib "kernel32" _
(ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Public Declare Function ProcessFirst Lib "kernel32" _
Alias "Process32First" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Public Declare Function ProcessNext Lib "kernel32" _
Alias "Process32Next" _
(ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Public Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Public Declare Function TerminateProcess Lib "kernel32" _
(ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Public Declare Sub CloseHandle Lib "kernel32" _
(ByVal hPass As Long)
Public Function CloseProcess(EXEName As String) As Boolean
Dim hSnapShot As Long
Dim uProcess As PROCESSENTRY32
Dim hProcess As Long
CloseProcess = False
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0&)
If hSnapShot = -1 Then Exit Function
uProcess.dwSize = Len(uProcess)
If ProcessFirst(hSnapShot, uProcess) = 1 Then
Do
If LCase$(Left$(uProcess.szExeFile, InStr(1, uProcess.szExeFile, vbNullChar) - 1)) _
= LCase$(EXEName) Then
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, uProcess.th32ProcessID)
CloseProcess = TerminateProcess(hProcess, ByVal 0&) > 0
Exit Do
End If
Loop While ProcessNext(hSnapShot, uProcess)
End If
Call CloseHandle(hSnapShot)
End Function
Dim cnn As ADODB.Connection
Dim rst As ADODB.Recordset
Dim ssql As String
Sub teste()
'cria uma conexão ADO
Set cnn = New ADODB.Connection
Set rst = New ADODB.Recordset
'Na string de conexão, o caracter "aspas duplas" é substituído pelo
'correspondente em ASCII -> Chr(34)
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Planilha.xls" & _
";Extended Properties=" & Chr(34) & "Excel 8.0;HDR=Yes" & Chr(34)
'abre o recordset pelo nome da planilha
'Obs.:
'- No comando SELECT o nome da planilha vai entre chaves e
'com um "$" no final do nome
Set rst = cnn.Execute("Select * from [plan1$]")
MsgBox rst(0)
rst.Close
cnn.Close
Set rst = Nothing
Set cnn = Nothing
End Sub
Option Explicit
Private Sub importa()
Dim cnn As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim adcomm As New ADODB.Command
Dim caminho As String
Dim linha As Integer
Dim coluna As Integer
caminho = "D:\paulo\Projetos VB\ADO Arquivo Texto\"
'Conexão para arquivo texto sem cabeçalho:
'connCSV.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
'& caminho & ";Extended Properties='text;HDR=NO;FMT=Delimited'"
'Conexão para arquivo texto com cabeçalho e colunas
cnn.Open "Driver={Microsoft Text Driver (*.txt; *.csv)};Dbq=" _
& caminho & ";Extensions=asc,csv,tab,txt;HDR=NO;Persist Security Info=False"
rst.Open "Select * From TesteDeDados.txt", cnn, adOpenStatic, adLockReadOnly, adCmdText
linha = 1
coluna = 1
Do While Not rst.EOF
Cells(linha, coluna).Value = rst(0)
Cells(linha, coluna + 1).Value = rst(1)
rst.MoveNext
linha = linha + 1
Loop
cnn.Close
Set cnn = Nothing
End Sub