This code is written in an Agent… being called from an ACTION button, at the top of a DOCUMENT (document is open) from a Notes client.
Why would I get an error of “Variable: SOURCE not declared”
when trying to save this.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim agent As NotesAgent
Dim doc As NotesDocument
Dim Ticket As Variant
Dim tmp1 As String , tmp2 As String, tm As String, sc As String
'Set db = session.CurrentDatabase
Set db = New NotesDatabase("MNWDOM02/MGRP", "dispatchv6\test.nsf") ' Be sure to put in dispatch DB not archive
If Not (db.IsOpen) Then
Call db.Open("","")
End If
'Set doc = New NotesDocument(db)
Set doc = Source.Document
Subject: SOURCE not declared ??? - in an agent? is that the reason?
I need to run this from an agent… which is launched from an action button in a document… reason, other things are going on in the action button… THEN it will call this agent… is there something I need to change becasue of where its coming from? This seems to work FINE if I run it INSIDE the action… how can i move it OUT?
Subject: SOURCE not declared ???
Source is not declared in the agent.You can define Global variable and set Source before using the agent or refer to the Source by adding code like this:
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = workspace.CurrentDocument
Set doc = UIdoc.Document
Subject: SOURCE not declared ???
Because SOURCE isn’t defined. If this were an event where Source was a NotesUIDocument, you could do this, but it isn’t. You need to use
Dim ws As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Set uidoc = ws.CurrentDocument
and then you could use
Set doc = uidoc.Document
I suppose you could even call it Source instead of uidoc, but I think you would confuse people.
Subject: RE: SOURCE not declared ???
Well i had all that… I just had doc set differently…Set doc = New NotesDocument(db)
i guess that doesn’t do it… I’ll try yours…
thx
Subject: SOURCE not declared ???
the last line says “set doc = Source.Document”…well, it doesnt have any idea what “Source” is.
Just in the DIM section, add the following:
Dim ws as New NotesUIWorkspace
Dim Source as NotesUIDocument
set Source = ws.CurrentDocument
See if that will help