-
Notifications
You must be signed in to change notification settings - Fork 1
/
newMacrosUpdater.bas
95 lines (80 loc) · 3.06 KB
/
newMacrosUpdater.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
'MacroName:Updater
'MacroDescription:Synchronizes local macro books with those on the shared drive for both CAT and ACQ departments. Works with Connexion client 3.0 only
'Macro modified by: Tomasz Kalata, BookOps
'Last modified: March 4, 2022
'version 2.1 (2022-03-04): removed support for client 2.6 and bug fixes
Sub Main
Dim LocalMod
Dim RemoteMod
Dim RemoteFolder
Dim LocalFolder
Dim sFName As String
Dim nCount As Integer
Dim DirArr()
Dim i
Dim Synced
Dim ConnexDefaultDir As String
Synced = FALSE
ConnexDefaultDir = "C:\Program Files\OCLC\Connexion\Program\"
' Determine if Connexion installed in its default location
If Dir(ConnexDefaultDir) <> "" Then
'MsgBox "Found Connexion client in the default location."
LocalFolder = Environ("APPDATA") & "\OCLC\Connex\Macros\"
If Dir("S:\CATAL\Connex\macros\") <> "" Then
RemoteFolder = "S:\CATAL\Connex\macros\"
'MsgBox "Located macro backup directory at: " & RemoteFolder
ElseIf Dir("S:\ACQUI\Connex3macros\") <> "" Then
RemoteFolder = "S:\ACQUI\Connex3macros\"
'MsgBox "Located macro backup directory at: " & RemoteFolder
Else
MsgBox "Unable to locate macro backup directory on your shared drive."
End If
Else
MsgBox "Connexion client not found in its default directory: " & ConnexDefaultDir
End If
sFName = Dir(RemoteFolder & "*.mbk")
'MsgBox "first: " & sFName
If Len(sFName) = 0 Then
MsgBox "Can't connect to the shared folder at: " & RemoteFolder & ". Exiting..."
Goto Done
End If
' create an array of macrobooks present in the backup directory on the shared drive
ReDim DirArr(0)
nCount = 0
Do While sFName <> ""
If InStr("Bookops.mbk", sFName) = 0 And InStr("newMacros.mbk", SFName) = 0 Then
ReDim Preserve DirArr(nCount)
DirArr(nCount) = sFName
'MsgBox "added to DirArr: " & DirArr(nCount)
nCount = nCount + 1
End If
sFName = Dir
'MsgBox "next: " & sFName
Loop
For i = 0 to nCount -1
sFName = DirArr(i)
RemoteMod = FileDateTime(RemoteFolder & sFName)
If Dir(LocalFolder & sFName) <> "" Then
' existing macrobook
LocalMod = FileDateTime(LocalFolder & sFName)
Else
' new macrobook
FileCopy RemoteFolder & sFName, LocalFolder & sFName
MsgBox "Copying new macrobook:" & sFName & ". Click OK to continue."
Synced = TRUE
End If
If RemoteMod > LocalMod Then
'MsgBox sFName & Chr(10) & "Local: |" & LocalMod & "|" & Chr(10) & "Remote: |" & RemoteMod & "|"
FileCopy RemoteFolder & sFName, LocalFolder & sFName
'MsgBox "FileCopy " & RemoteFolder & sFName & ", " & LocalFolder & sFName
MsgBox "Copying newer version of: " & sFName & ". Click OK to continue."
Synced = TRUE
End If
Next
If Synced <> FALSE Then
MsgBox "Your local macrobooks have been updated."
Else
MsgBox "Your local macrobooks are up-to-date."
End If
Done:
End Sub