Processos no Microsoft 365 para configurar aplicativos do Office, resgatar chaves de produto e ativar licenças.
bom, deixo aqui um comando que consegui transferir de forma bem fácil uma tabela access para excel.
'******************************************************************
' Data e Hora : 23/03/2010 13:14
' Autor : Abel
' Objetivo : Transfere Tab ou Consulta do access para o Excel
'******************************************************************
Private Sub Comando0_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strWorksheetPath As String
Dim appExcel As Excel.Application
Dim strTemplatePath As String
Dim bks As Excel.Workbooks
Dim rng As Excel.Range
Dim rngStart As Excel.Range
Dim strTemplateFile As String
Dim wkb As Excel.Workbook
Dim wks As Excel.Worksheet
Dim lngCount As Long
Dim strPrompt As String
Dim strTitle As String
Dim strTemplateFileAndPath As String
Dim prps As Object
Dim strSaveName As String
Dim strTestFile As String
Dim strDefault As String
Set appExcel = CreateObject("Excel.Application")
strTemplatePath = "C:\TESTE"
strTemplateFile = "Teste.xltx"
strTemplateFileAndPath = strTemplatePath & strTemplateFile
strTestFile = Nz(Dir(strTemplateFileAndPath))
Debug.Print "Arquivo Teste: " & strTestFile
If strTestFile = " " Then
MsgBox strTemplateFileAndPath & " nenhum arquivo; " & "não pode criar planilha"
GoTo ErrorHandlerExit
End If
strWorksheetPath = "C:\TESTE"
Debug.Print "Nome da Planilha Temporária: " & strTemplateFileAndPath
Set bks = appExcel.Workbooks
Set wkb = bks.Add '(strTemplateFileAndPath)
Set wks = wkb.Sheets(1)
wks.Activate
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("somapedidos", dbOpenDynaset)
rst.MoveLast
rst.MoveFirst
lngCount = rst.RecordCount
If lngCount = 0 Then
MsgBox "Sem registros a exportar"
GoTo ErrorHandlerExit
Else
strPrompt = "Exportando " & lngCount & " registros para o Excel"
strTitle = "Exportando"
MsgBox strPrompt, vbInformation + vbOKOnly, strTitle
End If
Set rngStart = wks.Range("A2")
rngStart.Activate
With rst
Do Until .EOF
rngStart.Activate
rngStart.Value = Nz(![Vencto])
Set rng = appExcel.ActiveCell.Offset(columnoffset:=1)
rng.Value = Nz(![SomadeValor])
Set rng = appExcel.ActiveCell.Offset(columnoffset:=2)
rngStart.Activate
Set rngStart = appExcel.ActiveCell.Offset(rowoffset:=1)
.MoveNext
Loop
End With
MsgBox "Todos os registros foram exportados com sucesso...!"
Set prps = appExcel.ActiveWorkbook.BuiltInDocumentProperties
strSaveName = strWorksheetPath & prps("Title") & " - " & Format(Date, "d-mm-yyyy")
Debug.Print "Salvar Planilha como: " & strSaveName
On Error Resume Next
Kill strSaveName
On Error GoTo ErrorHandler
strPrompt = "Entre com nome do arquivo para salvar planilha"
strTitle = "Nome do arquivo"
strDefault = strSaveName
strSaveName = InputBox(prompt:=strPrompt, Title:=strTitle, Default:=strDefault)
wkb.SaveAs FileName:=strSaveName, FileFormat:=xlWorkbookDefault
appExcel.Visible = True
ErrorHandlerExit:
Exit Sub
ErrorHandler:
If Err = 429 Then
Set appExcel = CreateObject("Excel.Application")
Resume Next
Else
MsgBox "Erro nº: " & Err.Number & "; Descrição: " & Err.Description
Resume ErrorHandlerExit
End If
End Sub
Aproveitem.
Abel.