Experts

mcjann
mcjann used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Groupware Consultant
Commented:
For some reason, the code above and your question don't seem to match. What would you like to do with multiple documents in a view? If that's the case, you need to build code using db.UnprocessedDocuments, which is the collection of selected documents. Loop through them, and "export" one document each time.

Author

Commented:
sjef_bosman


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.application")
      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,"/","-") +" Rev "+ Cstr(Rev)
            
            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\_Content Template (with New Doc Routines).dot")      
            x1App.ActiveDocument.SaveAs ("H:Analysis\Content\"+FName + ".doc"      )
            x1App.Activewindow.close
            
      Next
      
      
      
      Set x1App=Nothing
      
      
      
      End Sub

Author

Commented:
Not a solution in the strictest sense of the word but your comment provoked additional thought and my question is resolved.
Sjef BosmanGroupware Consultant

Commented:
Okay... ;-)

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial