MyTetra Share
Делитесь знаниями!
Модуль обновления подключений
25.08.2017
07:58
Текстовые метки: vba, Connection, Refresh
Раздел: VBA


'=======================================================================================

Sub RefAllCon()

On Error Resume Next

tt = Timer


With ThisWorkbook


For Each con In .Connections

Application.StatusBar = "Обновление " & con

t = Timer

con.Refresh

t = Timer - t: Debug.Print Round(t, 2) & " " & con

Application.StatusBar = False

Next con

End With


tt = Timer - tt:: Debug.Print Round(tt, 2) & "==="

'ThisWorkbook.Connections("04_IncGretQuick_NonStr").Refresh

End Sub



'=======================================================================================

Function FnRefCon(ByVal strConName As String) As Boolean

Application.StatusBar = "Обновление " & strConName

Dim dDateRef As Date

Dim dDateDelta As Date

With ThisWorkbook.Connections(strConName)

dDateRef = .ODBCConnection.RefreshDate

dDateDelta = Now - dDateRef


If dDateDelta < "01:00:00" Then

Select Case MsgBox("Последнее обновление было " & dDateDelta & " назад." & _

vbCrLf & "Обновить " & strConName, 52, "Обновление " & strConName)

Case 6 ' Да

.Refresh

FnRefCon = True

Case 7 ' Нет

FnRefCon = True

End Select

Else

.Refresh

FnRefCon = True

End If

End With

Application.StatusBar = False

End Function


'=======================================================================================

Sub Ref_CSC()

Обновить = FnRefCon("01_Prod")

Обновить = FnRefCon("03_CSC")

End Sub


'=======================================================================================

Sub Ref_IncGret()

Обновить = FnRefCon("01_Prod")

Обновить = FnRefCon("04_IncGret")

End Sub


'=======================================================================================

Sub Ref_SAVES()

Обновить = FnRefCon("02_SAVES")

End Sub


'=======================================================================================

Sub Ref_CDU()

Обновить = FnRefCon("01_Prod")

Обновить = FnRefCon("11_CDU.v.2")

End Sub


'=======================================================================================

Sub Ref_NonStr()

Обновить = FnRefCon("01_Prod")

Обновить = FnRefCon("04_IncGret_NonStr(%)")

End Sub


'=======================================================================================

Sub Ref_PAD()

Обновить = FnRefCon("01_Prod")

Обновить = FnRefCon("04_IncGretQuick_PAD_RE2")

Обновить = FnRefCon("04_IncGretQuick_PAD_RS2")

End Sub



Так же в этом разделе:
 
MyTetra Share v.0.52
Яндекс индекс цитирования