Hallo,
ich hänge den Vormittag an folgendem Problem fest ohne wirklich weiter zu kommen.
Mit dem foldenden Scrip kopiere ich 2 Dateien in 2 unterschiedliche Verzeichnisse.
Sofern die Datei bereits vorhanden ist soll Sie in .org umbenannt werden anschließend wird die neue kopiert.
Bis dahin funktioniert das ganz wie es soll.
Nun möchte ich das Script ggf. auch für Updates benutzen können, d.h. in diesem Fall existiert bereits die "neue" Datei und eine .org!
Ich würde gerne erreichen, daß in diesem Fall die ORG-Datei unangetastet bleibt und die noch aktuelle Datei in .lst oder noch besser in .001 usw. umbenannt wird.
Hab es für erste u.a. mal versucht wie in Zeile 49 ff, leider ohne den gewünschten Erfolg.
Wenn ich erstmal einen Ansatz habe, dann wäre das ja auch einfach auf die Zeilen 63 ff übertragbar.
LG
opiwahn
ich hänge den Vormittag an folgendem Problem fest ohne wirklich weiter zu kommen.
Mit dem foldenden Scrip kopiere ich 2 Dateien in 2 unterschiedliche Verzeichnisse.
Sofern die Datei bereits vorhanden ist soll Sie in .org umbenannt werden anschließend wird die neue kopiert.
Bis dahin funktioniert das ganz wie es soll.
Nun möchte ich das Script ggf. auch für Updates benutzen können, d.h. in diesem Fall existiert bereits die "neue" Datei und eine .org!
Ich würde gerne erreichen, daß in diesem Fall die ORG-Datei unangetastet bleibt und die noch aktuelle Datei in .lst oder noch besser in .001 usw. umbenannt wird.
Visual Basic:
'*** Const for destination directory and source files ***
const sPathOTM = "\AppData\Roaming\Microsoft\Outlook\"
const sFileOTM = "VbaProject.OTM"
const sPathNSet = "\AppData\Local\Microsoft\Office\"
const sPathISet = "\AppData\Roaming\Microsoft\Office\"
const sFileUI = "olkexplorer.officeUI"
'********************************************************
dim oFSO
dim oSHELL
dim sInstPath
dim sUser
dim sPathOTMcpl
dim sPathNSetcpl
dim sPathISetcpl
dim oFile_new
set oFSO = CreateObject("Scripting.FileSystemObject")
set oShell = CreateObject("WScript.Shell")
'*** find actual source- and user path
sInstPath = oFSO.GetParentFolderName(WScript.ScriptFullName) & "\Install\"
sUser = oSHELL.ExpandEnvironmentStrings("%USERPROFILE%")
'*** create destination path
sPathOTMcpl = sUser & sPathOTM
sPathNSetcpl = sUser & sPathNSet
sPathISetcpl = sUser & sPathISet
'*** check if .OTM (Macro) and .officeUI (menu) already exist
'*** cancel installation by click "No" otherwise
'*** rename exist OTM and .officeUI file to .old and copy new files
if oFSO.FileExists (sPathOTMcpl & sFileOTM) then
if MsgBox ("An OTM file (Outlook Macro) already exists at" & vbcrlf & vbcrlf & _
sPathOTMcpl & vbcrlf & vbcrlf & _
"Would you continue the installation?" & vbcrlf & _
"In this case, the existing files (Macro & Menu) will renamed to *.old.", _
vbYesNo, "File already exists!") = vbNo then
Set oShell = nothing
Set oFSO = nothing
WScript.Quit
end if
set oFile_new = oFSO.GetFile(sPathOTMcpl & sFileOTM)
if LCase(oFSO.GetExtensionName(oFile_new)) = "org" Then
oFile_new.name = sFileOTM & ".lst"
else
oFile_new.name = sFileOTM & ".org"
end if
else
oFSO.copyfile sInstPath & sFileOTM, sPathOTMcpl
end if
if oFSO.FileExists (sPathNSetcpl & sFileUI) then
set oFile_new = oFSO.GetFile(sPathNSetcpl & sFileUI)
oFile_new.name = sFileUI & ".org"
oFSO.copyfile sInstPath & sFileUI, sPathNSetcpl
elseif oFSO.FileExists (sPathISetcpl & sFileUI) then
set oFile_new = oFSO.GetFile(sPathISetcpl & sFileUI)
oFile_new.name = sFileUI & ".org"
oFSO.copyfile sInstPath & sFileUI, sPathISetcpl
else
oFSO.copyfile sInstPath & sFileUI, sPathNSetcpl
end if
MsgBox "The macro and menu customization was successfully installed" & vbcrlf & _
"To use the macro, please open your outlook and enable it once with ALT-F11.", _
vbYes, "Installation complete"
Set oShell = nothing
Set oFSO = nothing
WScript.Quit
Hab es für erste u.a. mal versucht wie in Zeile 49 ff, leider ohne den gewünschten Erfolg.
Wenn ich erstmal einen Ansatz habe, dann wäre das ja auch einfach auf die Zeilen 63 ff übertragbar.
LG
opiwahn
Zuletzt bearbeitet: