Manage Learn to apply best practices and optimize your operations.

Printing Embedded Object in all selected documents from a view Action

Printing Embedded Object in all selected document from a view Action

I never imagined printing embedded excel objects from a view would cause so much trouble, it looked fairly simple before I started working on it. I started off by writing a simple function, which looped through all the objects in a richtext field, but doesn't seem to work with excel objects saved in 97 format. After spending about four hours trying to find the reason I gave up and wrote this other function which works fine with all versions of excel. As the second function only gets the object by name, which is fine with the application here as we have only one embedded object to print per document.

Here's the first function which should have worked fine but didn't:

Sub PrintEmbeddedStuff(doc As notesdocument)
	
	On Error Resume Next
	
	If doc.hasembedded=False Then Exit Sub
	
	Dim handle As Variant
	Forall o In doc.EmbeddedObjects
		Print o.Name & " - " & o.Type & " - " & o.Class
		
		If o.Type = EMBED_OBJECT Then
			Set o1 = o
			Set handle=o.Activate(True)  ' show
			If Not handle Is Nothing Then
				Call handle.PrintOut()  ' prints the whole thing.
				Call handle.Quit()   ' close the object, if it hasnt done so already
			End If
			Delete handle
		End If
		
	End Forall
End Sub

Here's the second function which seem to work fine with all versions but only prints one object per document.

Sub PrintEmbeddedStuff(doc As notesdocument)
	
	On Error Resume Next
	
	If doc.hasembedded=False Then Exit Sub
	
	Dim handle As Variant
	Dim ws1 As Variant
	Dim o1 As notesembeddedobject
	
	Set ws1 = doc.getfirstitem("Rates")
	If Not (ws1 Is Nothing) Then
		Set o1 = ws1.getembeddedobject("Microsoft Excel Worksheet")
		If Not (o1 Is Nothing) Then
			Dim idisp As Variant
			Set idisp =  o1.activate(True)
			Call idisp.PrintOut()  ' prints the whole thing.
			Call idisp.Quit()   ' close the object, if it hasnt done so already
		End If
		Delete idisp
	End If
end function

Dig Deeper on Domino Resources

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchContentManagement

Close