?
Solved

Rename and detach attachments in multiple rt fields

Posted on 2004-11-15
9
Medium Priority
?
515 Views
Last Modified: 2013-12-18
Experts,

I have a form with multiple rich text fields each form does contain at least 1 embedded attachment.
For each rich text field (multiple rt fields exist i.e. more then 15 on the form).
I want to change the attached file name to DocNum & "_" & AttachName then put in a directory.
Prevously I have used the following code to extract a rich text item from a specific field but this form has multiple richtext fields.
Any help modify this code is needed fast!

If doc.HasEmbedded Then
 Set rtitem = doc.GetFirstItem( "FormBodyNat" ) ' name of field to look for attachment
   Forall o In rtitem.EmbeddedObjects
    If o.Type = EMBED_ATTACHMENT Then  
     Call o.ExtractFile( "h:\data\RMs\"+ FName+".doc") ' check file path for new location
     Call doc.Save( False, False)   ' no save and no change in doc status
    End If
End Forall

0
Comment
Question by:mcjann
  • 3
  • 2
  • 2
  • +1
9 Comments
 
LVL 24

Assisted Solution

by:HemanthaKumar
HemanthaKumar earned 600 total points
ID: 12586735
Try this

      If doc.HasEmbedded Then
            Forall fld In doc.Items
                  If fld.Type = RICHTEXT Then                        
                        Forall o In fld.EmbeddedObjects
                              If o.Type = EMBED_ATTACHMENT Then  
                                    Call o.ExtractFile( "h:\data\RMs\"+ FName+".doc") ' check file path for new location
                                    Call doc.Save( False, False)   ' no save and no change in doc status
                              End If
                        End Forall
                  End If
            End Forall
      End If

~Hemanth
0
 
LVL 1

Author Comment

by:mcjann
ID: 12586817
I incorporated the script like this and I am getting a type mismatch

Sub Click(Source As Button)
Dim session As New NotesSession  
Dim db As NotesDatabase  
Dim collection As NotesDocumentCollection  
Dim doc As NotesDocument  
Dim rtitem As Variant
      
Set db = session.CurrentDatabase  
Set collection = db.UnprocessedDocuments  
  For i = 1 To collection.Count    
            
     Set doc = collection.GetNthDocument( i )
      CRNum=doc.DocNum(0)
If doc.HasEmbedded Then
  Forall fld In doc.Items
    If fld.Type = RICHTEXT Then                    
      Forall o In fld.EmbeddedObjects
        If o.Type = EMBED_ATTACHMENT Then  
        Call o.ExtractFile( "h:\data\Night & Day\"+ CRNum+ "_" + o.source) ' check file path for new location
        Call doc.Save( False, False)   ' no save and no change in doc status
End If
End Forall
End If
End Forall
End If
Next
End Sub
0
 
LVL 24

Expert Comment

by:HemanthaKumar
ID: 12587000
Can you debug and let me know which line ?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 12587009
CRNum is a number?

Change
>      Call o.ExtractFile( "h:\data\Night & Day\"+ CRNum+ "_" + o.source) ' check file path for new location
to
       Call o.ExtractFile( "h:\data\Night & Day\" & CRNum & "_" + o.source) ' check file path for new location
0
 
LVL 1

Author Comment

by:mcjann
ID: 12587247
No, CRNum is a text field on the form.

I modified to the following and still get a type mismatch.

Forall fld In doc.Items
  If fld.Type = RICHTEXT Then      
Forall o In fld.EmbeddedObjects
                                    
     If o.Type = EMBED_ATTACHMENT Then  
          Print o.Type
         ' Call o.ExtractFile( "H:\DATA\Night & Day\" & CRNum & "_" + o.source) ' check file path for new location
          'Call doc.Save( False, False)   ' no save and no change in doc status
     End If
End Forall
End If
End Forall
End If
I am attempting anything to get it to work. Will the Forall fld In doc.Items cycle through all fields on the form?
0
 
LVL 14

Assisted Solution

by:p_partha
p_partha earned 1400 total points
ID: 12587306
Sub Click(Source As Button)
on error goto par
Dim session As New NotesSession  
Dim db As NotesDatabase  
Dim collection As NotesDocumentCollection  
Dim doc As NotesDocument  
Dim rtitem As Variant
   
Set db = session.CurrentDatabase  
Set collection = db.UnprocessedDocuments  
 For i = 1 To collection.Count    
         
    Set doc = collection.GetNthDocument( i )
      CRNum=doc.DocNum(0)
If doc.HasEmbedded Then
  Forall fld In doc.Items
   If fld.Type = RICHTEXT Then                    
    Forall o In fld.EmbeddedObjects
      If o.Type = EMBED_ATTACHMENT Then  
      Call o.ExtractFile( "h:\data\Night & Day\"+ CRNum+ "_" + o.source) ' check file path for new location
      Call doc.Save( False, False)   ' no save and no change in doc status
End If
End Forall
End If
End Forall
End If
Next
exit sub
par:
Msgbox "error occurred on line number " & erl & error
exit sub
End Sub

Now tell us the line number
0
 
LVL 1

Author Comment

by:mcjann
ID: 12587339
Line 18
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 12587346
Or use the debugger :)
0
 
LVL 14

Accepted Solution

by:
p_partha earned 1400 total points
ID: 12587389
try this :

      If doc.HasEmbedded Then
                  Forall fld In doc.Items
                        If fld.Type = RICHTEXT Then            
                              If Not Isempty(fld.embeddedobjects) Then
                                    Forall o In fld.EmbeddedObjects
                                          If o.Type = EMBED_ATTACHMENT Then  
                                                Call o.ExtractFile( "h:\data\Night & Day\"+ CRNum+ "_" + o.source) ' check file path for new location
                                                Call doc.Save( False, False)   ' no save and no change in doc status
                                          End If
                                    End Forall
                              End If
                        End If


Partha
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For Desktop Techs: How to retain a user's Notes configuration data when swapping out the end user's computer. (Assuming that you are not upgrading to a completely different version of Notes client) All you need to do is: 1) install Notes o…
  In today’s Arena we can’t imagine our lives without Internet as we are highly used to of it. If we consider our life style just for only 2 min we found that face to face communication is swapped by e-communication.  Every Where from Works place to…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Integration Management Part 2
Suggested Courses
Course of the Month14 days, 4 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question