Ask the Expert

Import a picture into a document, not as a link

Can LotusScript be used to import a picture into a document so that when the document is opened you see the both the picture (not just a link) and the other information on the document?

Of course! Here's a snippet:

Dim nudCurrent As NotesUIDocument
Dim sFilename As String
Dim iTempCount As Long
Dim sTemp As String
Dim sFileExtension As String
Dim wsCurrent As New NotesUIWorkspace
Set nudCurrent = wsCurrent.CurrentDocument

sFilepath = Input$("Enter the file path:")
sFilename = Input$("Enter the filename to import:")
'Get extension
If Instr(sFilename, ".") > 0 Then
	iTempCount = 1
	sTemp = Right$(sFilename, iTempCount)
	While Left$(sTemp, 1) <> "."
		iTempCount = iTempCount + 1
		sTemp = Right$(sFilename, iTempCount)
	sFileExtension = Right$(sFilename, iTempCount - 1)
	sFileExtension = ""
	iTempCount = 0
End If
sFileExtension = Ucase$(sFileExtension)
If (sFileExtension = "JPG" Or sFileExtension = "GIF" Or sFileExtension = "CGM" Or sFileExtension = "BMP") Then
	Call nudCurrent.GotoField("Body") ?a RT Field
	Select Case sFileExtension
	Case "JPG":
		sFiletype = "JPEG Image"
	Case "GIF":
		sFiletype = "GIF Image"
	Case "CGM":
		sFiletype = "ANSI Metafile"
	Case "BMP":
		sFiletype = "BMP Image"
	Case Else
		sFileType = "ASCII Text"
	End Select
	Call nudCurrent.Import(sFiletype, sFilepath & "\" & sFilename)

As you can see the hard part is getting the file name and type.

This was first published in April 2002

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: