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
|
On Error GoTo endE
'For stand alone utility ---------------------------------------------------
With ActiveWorkbook.Connections("owssvr[1]")
'For the Add-In utility ----------------------------------------------------
'With Workbooks(WBo).Connections("owssvr[1]")
'---------------------------------------------------------------------------
'Application.DisplayAlerts = False
Err.Clear
Select Case .Type
Case xlConnectionTypeODBC
With .ODBCConnection
.Refresh
Do While .Refreshing
DoEvents
Loop
End With
Case xlConnectionTypeOLEDB 'Our connection is OLE DB Type = 1
With .OLEDBConnection
.Refresh
Do While .Refreshing
DoEvents
Loop
End With
a = Err.Description
If a = Empty Then DataRefresh = True
Case Else
'Sorry, it's not possible
.Refresh
End Select
End With
endE:
Select Case DataRefresh
Case False
a = Err.Description
BoxText = "data-base refresh failed." & vbCrLf
BoxText = BoxText & "1. Make sure you have grantted access to the SharePoint." & vbCrLf
BoxText = BoxText & "2. Make sure you log in Intranet." & vbCrLf
BoxText = BoxText & "3. Request for support to this Utility Development team." & vbCrLf
u = VBA.MsgBox(BoxText, vbCritical, "DATA-BASE CONNECTION ERROR")
Case True
a = Err.Description
BoxText = "data-base refresh has been successfully completed." & vbCrLf & "You can run the tool..."
u = VBA.MsgBox(BoxText, vbInformation, "DATA-BASE CONNECTION SUCCESSFULL")
End Select |
Partager