Hi,
I have a agent that loads the contents of excel data to a notes view.
I have a ProfileDocument with the item names to verify in Excel and import to the notes view…
This is my code:Set ws = New NotesUIWorkspace
Set session = New NotesSession
Set db = session.CurrentDatabase
Set col=db.UnprocessedDocuments
Set doc=col.GetFirstdocument
Set uidoc = ws.currentdocument
If doc.HasEmbedded Then
Forall o In doc.EmbeddedObjects
Set object=o
End Forall
If Not ( object Is Nothing ) Then
Set excel = object.Activate( False)
If Not( excel Is Nothing ) Then
Set profdoc = db.GetProfileDocument(“configuracao”)
If Not (profdoc Is Nothing) Then
Set worksheet = excel.Application.Workbooks(1).Sheets(1)
If Not (worksheet Is Nothing) Then
If (doc.form(0)=“aspectos_empresa” Or doc.form(0)=“aspectos_maquina”) Then
upperBound% = Ubound(profdoc.caspectosCFG)
counter% = 0
While (counter%) <= upperBound%
Set cell = worksheet.Range(profdoc.caspectosCFG(counter%))
Set item = doc.ReplaceItemValue _
( Cstr(profdoc.caspectosCFG(counter%)) & "ASP", cell.value )
counter% = counter% + 1
Wend
Elseif (doc.form(0)="perigos_maquina"Or doc.form(0)=“perigos_area”) Then
upperBound% = Ubound(profdoc.cperigosCFG)
counter% = 0
While (counter%) <= upperBound%
Set cell = worksheet.Range(profdoc.cperigosCFG(counter%))
Set item = doc.ReplaceItemValue _
( Cstr(profdoc.cperigosCFG(counter%)) & "PRG", cell.value )
counter% = counter% + 1
Wend
End If
Call doc.Save(False, False)
End If
End If
End If
End If
End If
My problem is that when i do:
Set cell = worksheet.Range(profdoc.cperigosCFG(counter%))
I get the ole automation error, because that cell don’t exits in one of my excel’s.
How can I verify if that range exists in the excel before i set cell?
Thanks in advance
Carla