Avatar of mcjann
mcjann
 asked on

Experts

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
Lotus IBM

Avatar of undefined
Last Comment
Sjef Bosman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Sjef Bosman

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
mcjann

ASKER
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
mcjann

ASKER
Not a solution in the strictest sense of the word but your comment provoked additional thought and my question is resolved.
Sjef Bosman

Okay... ;-)
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck