I have inherited a shared action that works very well on a single document selected in a view. However I am struggling to make this work as an action that can be performed against each document in a view.
There is a type mismatch, that I don't understand, when attempting to set doc to uidoc of vice versa.
Any suggestions?
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set x1App=CreateObject("Word.application")
x1App.Visible = False
Call workspace.EditDocument( False )
Set uidoc = workspace.CurrentDocument
Call uidoc.ExpandAllSections
Call uidoc.Copy
'get all document info
Num = uidoc.Fieldgettext("DocNum")
Rev = uidoc.Fieldgettext("Revision")
FName=Replace(Num,"/","-") +" Rev "+ Cstr(Rev)
'save the document into MS Word format
x1App.Documents.Add ("H:\DATA\_2012 Lotus Notes\Doc Ctrl\My Extracted Atts and Analysis\Content\_Content Template (with New Doc Routines).dot")
' the template specified has additional code to run on each new document (i.e. pasting content and clean up)
x1App.ActiveDocument.SaveAs ("H:\DATA\_2012 Lotus Notes\Doc Ctrl\My Extracted Atts and Analysis\Content\"+FName + ".doc" )
Call uidoc.Close
x1App.Activewindow.close
Set x1App=Nothing
End Sub
ASKER
Appologize for the delay response but I was off on vacation and swmped when I returned.
Your comment made me go back and look again for something simple and I changed the code so to call an a specific view, set the doc and set uidoc to doc. Not sure how efficient I am but this is the code that I have working now:
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim uiview As NotesUIView
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set x1App=CreateObject("Word.a
x1App.Visible = True
Set db=session.currentdatabase
Set dc=db.UnprocessedDocuments
Set uiview = workspace.CurrentView
For j =1 To dc.count
Set doc=dc.getnthdocument(j)
'get all document info
Num = doc.DocNum(0)
Rev = doc.Revision(0)
FName=Replace(Num,"/","-")
Call uiview.SelectDocument(doc)
Call workspace.EditDocument( False )
Set uidoc = workspace.CurrentDocument
Call uidoc.ExpandAllSections
Call uidoc.Copy
Call uidoc.Close(True)
'Set uidoc=Nothing
'save the document into MS Word format
' the template specified has additional code to run on each new document (i.e. pasting content and clean up)
x1App.Documents.Add ("H:Analysis\Content\_Cont
x1App.ActiveDocument.SaveA
x1App.Activewindow.close
Next
Set x1App=Nothing
End Sub