Skip to content

Commit 2d62840

Browse files
committed
Version 1.7.0 (accda)
1 parent 211b175 commit 2d62840

37 files changed

+8641
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/ACLibFilterFormWizard.accdb

access-add-in/Install.vbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const AddInName = "ACLib-FilterForm-Wizard"
2-
const AddInFileName = "ACLibFilterFormWizard.mda"
3-
const MsgBoxTitle = "Update ACLib-FilterForm-Wizard"
2+
const AddInFileName = "ACLibFilterFormWizard.accda"
3+
const MsgBoxTitle = "Install ACLib-FilterForm-Wizard"
44

55
MsgBox "Vor dem Aktualisieren der Add-In-Datei darf das Add-In nicht geladen sein!" & chr(13) & _
66
"Zur Sicherheit alle Access-Instanzen schließen.", , MsgBoxTitle & ": Hinweis"

source/ACLibWebImporter.cls

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,207 @@
1+
VERSION 1.0 CLASS
2+
BEGIN
3+
MultiUse = -1 'True
4+
END
5+
Attribute VB_Name = "ACLibWebImporter"
6+
Attribute VB_GlobalNameSpace = False
7+
Attribute VB_Creatable = False
8+
Attribute VB_PredeclaredId = False
9+
Attribute VB_Exposed = False
10+
'---------------------------------------------------------------------------------------
11+
' Klassenmodul: ACLibWebImporter
12+
'---------------------------------------------------------------------------------------
13+
'/**
14+
' <summary>
15+
' Hilfsklasse zum Importieren von Codemodulen aus der Code-Bibliothek in die usys_Appfiles-Tabelle
16+
' </summary>
17+
' <remarks>
18+
' </remarks>
19+
'\ingroup addins_shared
20+
'**/
21+
'---------------------------------------------------------------------------------------
22+
'<codelib>
23+
' <file>_codelib/addins/shared/ACLibWebImporter.cls</file>
24+
' <license>_codelib/license.bas</license>
25+
'</codelib>
26+
'---------------------------------------------------------------------------------------
27+
'
28+
Option Compare Database
29+
Option Explicit
30+
31+
Const SvnBaseUrl As String = "https://svn.access-codelib.net/svn/codelib/"
32+
33+
Private m_SvnRev As String
34+
Private m_UseDraftBranch As Boolean
35+
36+
#If VBA7 Then
37+
Private Declare PtrSafe Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
38+
Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
39+
#Else
40+
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
41+
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
42+
#End If
43+
44+
Public Property Get UseDraftBranch() As Boolean
45+
UseDraftBranch = m_UseDraftBranch
46+
End Property
47+
48+
Public Property Let UseDraftBranch(ByVal NewValue As Boolean)
49+
m_UseDraftBranch = NewValue
50+
End Property
51+
52+
Public Property Get CurrentSvnRev(Optional ByVal RequerySvnRev As Boolean = False) As String
53+
If Len(m_SvnRev) = 0 Or RequerySvnRev Then
54+
m_SvnRev = GetRevisionFromWeb
55+
If UseDraftBranch Then
56+
m_SvnRev = m_SvnRev & "-draft"
57+
End If
58+
End If
59+
CurrentSvnRev = m_SvnRev
60+
End Property
61+
62+
Public Sub UpdateCodeModules()
63+
64+
Dim SelectSql As String
65+
Dim IsFirstRecord As Boolean
66+
67+
SelectSql = "select id, url from usys_Appfiles where url > ''"
68+
69+
With CreateObject("ADODB.Recordset")
70+
.CursorLocation = 3 'adUseClient
71+
.Open SelectSql, CodeProject.Connection, 1, 1 ' 1 = adOpenKeyset, 1 = adLockReadOnly
72+
Set .ActiveConnection = Nothing
73+
74+
IsFirstRecord = True
75+
Do While Not .EOF
76+
UpdateCodeModuleInTable .Fields(0).Value, .Fields(1).Value, IsFirstRecord
77+
If IsFirstRecord Then IsFirstRecord = False
78+
.MoveNext
79+
Loop
80+
81+
.Close
82+
83+
End With
84+
85+
End Sub
86+
87+
Private Sub UpdateCodeModuleInTable(ByVal ModuleName As String, ByVal ACLibPath As String, Optional ByVal RequerySvnRev As Boolean = False)
88+
89+
Dim TempFile As String
90+
Dim DownLoadUrl As String
91+
92+
TempFile = FileTools.TempPath & ModuleName & ".cls"
93+
94+
DownLoadUrl = SvnBaseUrl
95+
If UseDraftBranch Then
96+
DownLoadUrl = DownLoadUrl & "branches/draft"
97+
Else
98+
DownLoadUrl = DownLoadUrl & "trunk/codelib"
99+
End If
100+
DownLoadUrl = DownLoadUrl & ACLibPath
101+
102+
DownloadFileFromWeb DownLoadUrl, TempFile
103+
CurrentApplication.SaveAppFile ModuleName, TempFile, True, "SvnRev", Me.CurrentSvnRev(RequerySvnRev)
104+
Kill TempFile
105+
106+
End Sub
107+
108+
Private Function GetRevisionFromWeb() As Long
109+
110+
Const RevisionTag As String = "Revision "
111+
112+
Dim IE As Object ' SHDocVw.InternetExplorer
113+
Dim HtmlDoc As Object ' MSHTML.HTMLDocument
114+
Dim HtmlElements As Object ' MSHTML.IHTMLElementCollection
115+
Dim RevText As String
116+
117+
OpenIEandLoadHtmlDoc SvnBaseUrl, IE, HtmlDoc
118+
119+
Set HtmlElements = HtmlDoc.getElementsByTagName("H2")
120+
121+
If HtmlElements.Length > 0 Then
122+
RevText = HtmlElements.Item.innerText
123+
Else
124+
Err.Raise vbObjectError, "GetRevisionFromWeb", "Text mit Revisionsnummer fehlt in '" & SvnBaseUrl & "'"
125+
End If
126+
127+
Set HtmlElements = Nothing
128+
HtmlDoc.Close
129+
Set HtmlDoc = Nothing
130+
131+
IE.Quit
132+
Set IE = Nothing
133+
134+
Dim RevPos As Long
135+
136+
RevPos = InStr(1, RevText, RevisionTag)
137+
If RevPos = 0 Then
138+
Err.Raise vbObjectError, "GetRevisionFromWeb", "Text mit Revisionsnummer fehlt in '" & SvnBaseUrl & "'"
139+
End If
140+
RevText = Mid(RevText, RevPos + Len(RevisionTag))
141+
142+
GetRevisionFromWeb = Val(RevText)
143+
144+
End Function
145+
146+
Private Sub OpenIEandLoadHtmlDoc(ByVal Url As String, ByRef IE As Object, ByRef HtmlDoc As Object)
147+
148+
Dim TimeOut As Long
149+
Dim RunInTimeOut As Boolean
150+
Dim ErrHdlCnt As Long
151+
152+
Dim ErrNumber As Long
153+
Dim ErrDescription As String
154+
155+
On Error Resume Next
156+
Set IE = CreateObject("InternetExplorer.Application")
157+
Do While Err.Number = -2147023706 And ErrHdlCnt < 10
158+
Err.Clear
159+
ErrHdlCnt = ErrHdlCnt + 1
160+
Set IE = CreateObject("InternetExplorer.Application")
161+
Loop
162+
163+
If Err.Number <> 0 Then
164+
ErrNumber = Err.Number
165+
ErrDescription = Err.Description
166+
On Error GoTo 0
167+
Err.Raise ErrNumber, "ACLibWebImporter.OpenIEandLoadHtmlDoc", ErrDescription
168+
End If
169+
170+
On Error GoTo 0
171+
172+
With IE
173+
TimeOut = Timer + 10
174+
Do While .Busy And (Not RunInTimeOut)
175+
DoEvents
176+
If Timer > TimeOut Then RunInTimeOut = True
177+
Loop
178+
179+
If Not RunInTimeOut Then
180+
.Visible = 0
181+
.navigate Url
182+
TimeOut = Timer + 10
183+
Do Until .ReadyState = 4 Or RunInTimeOut
184+
DoEvents
185+
If Timer > TimeOut Then RunInTimeOut = True
186+
Loop
187+
End If
188+
189+
If RunInTimeOut Then
190+
On Error Resume Next
191+
IE.Quit
192+
Set IE = Nothing
193+
On Error GoTo 0
194+
Err.Raise vbObjectError, "OpenIEandLoadHtmlDoc", "Time-Out beim Laden von '" & Url & "'"
195+
End If
196+
197+
Set HtmlDoc = IE.Document
198+
199+
End With
200+
201+
End Sub
202+
203+
Private Sub DownloadFileFromWeb(ByVal Url As String, ByVal TargetPath As String)
204+
If FileExists(TargetPath) Then Kill TargetPath
205+
DeleteUrlCacheEntry Url
206+
URLDownloadToFile 0, Url, TargetPath, 0, 0
207+
End Sub

0 commit comments

Comments
 (0)