PDA

View Full Version : Office 2003 To office 2007 macros (FileSearch)



elielhf
06-14-2012, 03:32 AM
Hello,

I'm working with the Office 2007 now, but I'm with macros that is not working because, this macros use the command "Application.FileSearch".

How can I change my code for the Office 2007.

I want to change but I don't know how can I do that.

Function Executa_Tudo(ARQUIVO, NomeArquivo)
Dim Endereco As String
Dim i, u As Integer
Dim pasta As String
Dim Existe_Campo1, Existe_Campo2, Existe_Campo3 As Variant
' Declaração das classes
Dim Canaletafront As New CCanaleta_Front
Dim canaletaRear As New CCanaleta_rear
Dim CanaletaLOP As New CCanaletaLOP
Dim CanaletaLP As New CCanaletaLP
Dim Crown As New CCrown
Dim FPPRear As New CFPP_rear
Dim FPVRear As New CFPV_Rear
Dim front As New CFront
Dim Rear As New CLado_rear
Dim LadoPressao As New CLadoPressao
Dim LOP As New CLOP
Dim Pinos As New CPinos
Dim Undercrown As New CUnderCrown
Dim fotos As Tfotos
Dim a, b, c, d, e, f, g, h, m, j, k, l As Variant
Novo_Endereço:
Endereco = BrowseDialog(0, "Selecione o endereço das fotos a serem inseridas")

If (Endereco <> "") Then
With Application.FileSearch
.FileName = "*.jpg"
.LookIn = Endereco
.SearchSubFolders = False
.Execute
If (.FoundFiles.Count > 0) Then
For i = 1 To .FoundFiles.Count
NomeArquivo = Dir(Application.FileSearch.FoundFiles(i))

Existe_Campo1 = Switch(NomeArquivo = "Pistão1_Topo.JPG", 10, NomeArquivo = "Pistão3_Topo.JPG", 28, _
NomeArquivo = "Pistão5_Topo.JPG", 46, NomeArquivo = "Pistão1_Boca.JPG", 64, NomeArquivo = "Pistão3_Boca.JPG", _
82, NomeArquivo = "Pistão5_Boca.JPG", 100, NomeArquivo = "Pistão1_L.P..JPG", 118, NomeArquivo = _
"Pistão3_L.P..JPG", 136, NomeArquivo = "Pistão5_L.P..JPG", 154, NomeArquivo = "Pistão1_L.O.P..JPG", 172, _
NomeArquivo = "Pistão3_L.O.P..JPG", 190, NomeArquivo = "Pistão5_L.O.P..JPG", 208, _


THANK YOU.

John Wilson
06-17-2012, 12:45 PM
FileSearch was removed in 2007.

You will need to rewrite using another method (which will probably also work in 2003)

Example File system object mthod

http://support.microsoft.com/kb/185601/