GaryStone10
Board Regular
- Joined
- Nov 18, 2008
- Messages
- 100
Hi All
I'm hoping this is possible. I have a report that loads up scanned documents from another application. This is done by using a reference to the other application and works fine. However, there will be people that don't have the other application and therefore not have the reference, so I wanted to add some error handling to give them a specific error. This is my code.
The issue is that the macro fails on this line
Dim ados_server As New ADOSServer
Which I believed the error handling should have taken care of. Any ideas what else I can do?
Many thanks in advance
Gary Stone
I'm hoping this is possible. I have a report that loads up scanned documents from another application. This is done by using a reference to the other application and works fine. However, there will be people that don't have the other application and therefore not have the reference, so I wanted to add some error handling to give them a specific error. This is my code.
Code:
Sub Open_Ados(reporttarget As Range, Optional region As Boolean)
'This sub is used to open ADOS Viewer (if possible) to load up the document relating to the data clicked on.
'This only works if the user has ADOS access and ADOS installed on the desktop, otherwise it takes you to the
'error message
On Error GoTo adoserr
Dim ados_server As New ADOSServer
Dim ados_document As New ADOSDocument
Dim docnorow As Integer
Dim docno As Long
Dim claimdata As Worksheet
Unprotect_sheets
'set the sheet used
If region = True Then
Set claimdata = Sheets("Region Claim Data")
Else
Set claimdata = Sheets("Claim Data")
End If
'set the server and connect to it
Set ados_server = CreateObject("TWADOSObjects.ADOSServer")
ados_server.Connect 1
'find the corresponding row to the cell clicked on and the docno from that row
If reporttarget.Column < 11 Then
docnorow = (reporttarget.Row - 112) + (10 * ((reporttarget.Column - 2) / 3))
docno = claimdata.Cells(docnorow, 3)
Else
docnorow = (reporttarget.Row - 112) + (10 * (reporttarget.Column - 11))
docno = claimdata.Cells(docnorow, 7)
End If
'load up the document as if it was a hyperlink, this is the easiest way to open it within ADOS Viewer
ThisWorkbook.FollowHyperlink ados_document.Retrieve(docno, "", ados_server)
ThisWorkbook.Activate
protect_sheets
Exit Sub
adoserr:
MsgBox "It was not possible to load this document. This may be due to ADOS not being installed on the computer, or incorrect access rights.", , "Error accessing document"
protect_sheets
End Sub
Dim ados_server As New ADOSServer
Which I believed the error handling should have taken care of. Any ideas what else I can do?
Many thanks in advance
Gary Stone