Exemplificando, utilizar as funções do Excel no Word através do VBA, veja nas figuras mais abaixo.
Não esquecer de marcar a referência do Excel na versão do Office instalado.
;-)
Eventualmente dicas sobre outros programas, Windows e hardware.
Dim MyCheck
MyCheck = "aBBBa" Like "a*a" ' Retorna True.
MyCheck = "F" Like "[A-Z]" ' Retorna True.
MyCheck = "F" Like "[!A-Z]" ' Retorna False.
MyCheck = "a2a" Like "a#a" ' Retorna True.
MyCheck = "aM5b" Like "a[L-P]#[!c-e]" ' Retorna True.
MyCheck = "BAT123khg" Like "B?T*" ' Retorna True.
MyCheck = "CAT123khg" Like "B?T*" ' Retorna False.
Private Sub cmdFileDialog_Click()
' Requires reference to Microsoft Office 11.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
' Clear listbox contents.
Me.FileList.RowSource = ""
' Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
' Allow user to make multiple selections in dialog box
.AllowMultiSelect = True
' Set the title of the dialog box.
.Title = "Please select one or more files"
' Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB"
.Filters.Add "Access Projects", "*.ADP"
.Filters.Add "All Files", "*.*"
' Show the dialog box. If the .Show method returns True, the
' user picked at least one file. If the .Show method returns
' False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
Me.FileList.AddItem varFile
Next
Else
MsgBox "You clicked Cancel in the file dialog box."
End If
End With
End Sub
Option Compare Database
Option Explicit
Sub AnexaArquivo()
Dim rs As DAO.Recordset
Dim rsAnexo As DAO.Recordset
Dim db As DAO.Database
Set db = CurrentDb()
db.Execute "DELETE FROM tabela1"
Set rs = db.OpenRecordset("tabela1")
rs.AddNew
Set rsAnexo = rs.Fields("CampoAnexo").Value
rsAnexo.AddNew
rsAnexo.Fields("FileData").LoadFromFile "c:\teste.txt"
rsAnexo.Update
rs.Update
rs.Close
Set rs = Nothing
Set db = Nothing
End Sub
Option Compare Database
Option Explicit
Dim rst As ADODB.Recordset
Dim ssql As String
Dim acumulador As Double
Dim i As Integer
Public Function Atualiza_IGPM(MesInicio As Integer, _
AnoInicio As Integer, _
MesFim As Integer, _
AnoFim As Integer, _
valor As Double) As Double
ssql = "SELECT * FROM tabela1 WHERE "
ssql = ssql & "DataIndice >= #" & MesInicio & "/1/" & AnoInicio & "#"
ssql = ssql & "ORDER BY DataIndice"
Set rst = New ADODB.Recordset
rst.Open ssql, CurrentProject.Connection, adOpenKeyset, adLockOptimistic
rst.MoveFirst
'Primeiro índice
acumulador = 0
acumulador = (rst!indice / 100) + 1
rst.MoveNext
Do While Not rst.EOF
'Acumular taxas
acumulador = acumulador * ((rst!indice / 100) + 1)
If rst!mes = MesFim And rst!ano = AnoFim Then
Exit Do
Else
rst.MoveNext
End If
Loop
Atualiza_IGPM = Round(valor * ((acumulador - 1) * 100), 5)
rst.Close
Set rst = Nothing
End Function