Na rotina abaixo que deteta qual o Office 32 ou 64 como, unir os dois código e ler o que necessita.
Códigos a unir:
Porque ao ser executada a que estiver primeiro é que conta, se a outra estiver desativada.
Caso nenhuma estiver desativada não comprime
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
'Windows 10 64 - winrar 64 - Office 2013 32
If Len(Dir("PROGRAMFILES") & "\Winrar\WinRar.EXE") & "" > 0 Then
WinRarPath = "C:\Program Files\WinRar\"
End If
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
'Windows 10 64 - winrar 64 - Office 2016 64
If Len(Dir("C:\Program Files (x86)\") & "Winrar\WinRAR.EXE") & "" > 0 Then
WinRarPath = "C:\Program Files (x86)\WinRar\"
End If
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
Rotina completa abaixo:
Sub ComprimePastaComWinRar()
Dim Msg As String
On Error GoTo 1
'*******************************************
Dim FSO As Object
Dim FromPath As String
Dim ToPath As String
Dim WinRarPath As String 'Localização do WinRar.exe
Dim RarIt As String 'Instrução de linha de comando
Dim SourceDir As String 'O diretório de origem
Dim DestDir As String 'O diretório de destino
Dim DestRarName As String
Dim Dest As String 'Caminho de destino concatenado
FromPath = Me!CaminhoEscolhido
ToPath = Me!CaminhoEscolhido
'inicia a criação da pasta
Set fs = CreateObject("Scripting.FileSystemObject")
'se a pasta existir, deleta
If Right(FromPath, 1) = "\" Then
FromPath = Left(FromPath, Len(FromPath) - 1)
End If
If Right(ToPath, 1) = "\" Then
ToPath = Left(ToPath, Len(ToPath) - 1)
End If
Set FSO = CreateObject("scripting.filesystemobject")
If FSO.FolderExists(FromPath) = False Then
MsgBox FromPath & " Não Existe."
Exit Sub
End If
'copia
FSO.CopyFolder Source:=FromPath, Destination:=ToPath
'*** Verifica se existe instalação do WinRar ***
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
'Windows 10 64 - winrar 64 - Office 2013 32
If Len(Dir("PROGRAMFILES") & "\Winrar\WinRar.EXE") & "" > 0 Then
WinRarPath = "C:\Program Files\WinRar\"
End If
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
'Windows 10 64 - winrar 64 - Office 2016 64
If Len(Dir("C:\Program Files (x86)\") & "Winrar\WinRAR.EXE") & "" > 0 Then
WinRarPath = "C:\Program Files (x86)\WinRar\"
End If
'$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
SourceDir = Me.CaminhoEscolhido
'Verifica se a Pasta tem espaços nos nomes
If InStr(1, SourceDir, " ", vbTextCompare) <> 0 Then SourceDir = Chr(34) & SourceDir & Chr(34)
'Letra do Drive de destino
DestDir = Me.CaminhoEscolhido
If Dir(DestDir, vbDirectory) = "" Then MkDir DestDir
DestRarName = "Backup.Rar"
Dest = DestDir & "\" & DestRarName
If InStr(1, Dest, " ", vbTextCompare) <> 0 Then Dest = Chr(34) & Dest & Chr(34)
RarIt = shell(WinRarPath & "Winrar.exe a -r " & Dest & " " & SourceDir, vbHide)
MsgBox "Backup Complecto Criado com Sucesso...", vbInformation, "" & DLookup("[Programa]", "Proprietario") & " " & DLookup("[Tipo]", "Proprietario")
Me.Rótulo11.Caption = "A Compactar ..."
volta:
If ProgramaAtivo("WinRar") = True Then
Pause (5)
GoTo volta
End If
Call Comando25_Click
Exit_1:
DoCmd.Hourglass False
DoCmd.Echo True
Exit Sub
1 A:
DoCmd.Hourglass False
DoCmd.Echo True
Msg = "Erro # " & Str(Err.Number) & " gerado na " & Err.Source _
& vbNewLine & vbNewLine & "Descrição: " & Err.Description _
& vbNewLine & vbNewLine & "Por favor contate o Administrador de Sistema."
MsgBox Msg, vbMsgBoxHelpButton + vbCritical, "Erro", Err.HelpFile, Err.HelpContext
Resume Exit_1
End Sub
Obrigado