Thema Datum  Von Nutzer Rating
Antwort
27.10.2020 12:01:26 Eyyub
NotSolved
27.10.2020 12:08:50 Eyyub
NotSolved
27.10.2020 12:09:50 Eyyub
NotSolved
Blau Problem mit WshShell
27.10.2020 12:39:45 Gast65809
****
Solved
27.10.2020 13:20:10 Eyyub
NotSolved
27.10.2020 13:38:26 Gast65809
*****
Solved
02.11.2020 12:00:38 Eyyub
NotSolved
27.10.2020 12:43:19 Mase
NotSolved

Ansicht des Beitrags:
Von:
Gast65809
Datum:
27.10.2020 12:39:45
Views:
513
Rating: Antwort:
 Nein
Thema:
Problem mit WshShell

Probier mal so:

Option Explicit

Sub Test()
  
  zipFile ActiveSheet.Parent.Path & "\" & Date
  
End Sub

Private Sub zipFile(ByVal Path As String)
  
  Const C_7Z_PATH = "%PROGRAMFILES%\7-Zip\7z.exe"
  
  If Right$(Path, 1) <> "\" _
    Then Path = Path & "\"
  
  Dim strCommand As String
  
  strCommand = """{7Z_PATH}"" a -tzip ""{SAVE_TO_ARCHIVE}"" ""{FOLDER_TO_SAVE}"""
  
  strCommand = Replace$(strCommand, "{7Z_PATH}", C_7Z_PATH, Compare:=vbTextCompare)
  strCommand = Replace$(strCommand, "{SAVE_TO_ARCHIVE}", Path & "archive_name", Compare:=vbTextCompare)
  strCommand = Replace$(strCommand, "{FOLDER_TO_SAVE}", Path, Compare:=vbTextCompare)
  
  Dim lngErrorCode As Long
  
  With New WshShell
    lngErrorCode = .Run(strCommand, WindowStyle:=1, WaitOnReturn:=1)
    Select Case lngErrorCode
      Case 1
        Call MsgBox("File Not Found!", vbCritical)
      Case 0
        Call MsgBox("OK!", vbInformation)
      Case Else
        Call MsgBox("Oh no! Something went wrong with Wsh!", vbCritical)
    End Select
  End With
  
End Sub

 


Ihre Antwort
  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen
Thema: Name: Email:



  • Bitte beschreiben Sie Ihr Problem möglichst ausführlich. (Wichtige Info z.B.: Office Version, Betriebssystem, Wo genau kommen Sie nicht weiter)
  • Bitte helfen Sie ebenfalls wenn Ihnen geholfen werden konnte und markieren Sie Ihre Anfrage als erledigt (Klick auf Häckchen)
  • Bei Crossposting, entsprechende Links auf andere Forenbeiträge beifügen / nachtragen
  • Codeschnipsel am besten über den Code-Button im Text-Editor einfügen
  • Die Angabe der Emailadresse ist freiwillig und wird nur verwendet, um Sie bei Antworten auf Ihren Beitrag zu benachrichtigen

Thema Datum  Von Nutzer Rating
Antwort
27.10.2020 12:01:26 Eyyub
NotSolved
27.10.2020 12:08:50 Eyyub
NotSolved
27.10.2020 12:09:50 Eyyub
NotSolved
Blau Problem mit WshShell
27.10.2020 12:39:45 Gast65809
****
Solved
27.10.2020 13:20:10 Eyyub
NotSolved
27.10.2020 13:38:26 Gast65809
*****
Solved
02.11.2020 12:00:38 Eyyub
NotSolved
27.10.2020 12:43:19 Mase
NotSolved