Hi Enkori, Hi Entwickler,
habe noch ein Script für den Bilder-Import.
Es müsste doch hier die Möglichkeit geben, die Breite und Höhe abzufragen.
Vielleicht hat jemand von Euch eine Idee?
Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim object As NotesEmbeddedObject
Dim filename As String
Dim ImageType As String
Dim ImageHeight As String
Dim ImageWidth As String
Dim ImageDepth As String
' Open a dialogbox and allow users to select from a list of files
' NB: PNG is missing from here as Notes can't import PNG image types.
files = workspace.OpenFileDialog(True, "File List", "Supported Images|*.jpg;*.bmp;*.gif", "C:\")
If Isempty(files) Then Exit Sub ' Exit if the user selects the Cancel button
Forall FileList In files ' Loop through the list of files selected
Filename = Filelist ' Get the current filename
' GetImageProperties returns an array of ImageType, height, width and bit-depth
imgProps = GetImageProperties(Filename)
ImageType = imgProps(0) ' Get the image type, BMP-GIF-JPEG-PNG
ImageHeight = imgProps(1) ' Get the image height
ImageWidth = imgProps(2) ' Get the image width
ImageDepth = imgProps(3) ' Get the image bit-depth
' Now, we will create a new document and attach the selected image to it.
Set db = session.CurrentDatabase ' Get the current database
Set doc = New NotesDocument( db ) ' Create a new Notes Doc
Set rtitem = New NotesRichTextItem( doc, "Image" ) ' Create a new richtext item
Set object = rtitem.EmbedObject ( EMBED_ATTACHMENT, "", filename) ' Attach the file to it
doc.Form = "ImageSize" ' Set the form name
doc.HEIGHT = Cint(ImageHeight) ' Write the height
doc.Width = Cint(ImageWidth) ' Write the width
doc.colordepth = Cint(ImageDepth) ' Write the colour depth
doc.filesize = Filelen(filename) ' Write the filename
Call doc.Save( True, True ) ' Save the backend document
' Once we have attached the image, we can open the document in the front-end and
' import the same file so we have a preview version.
Set uidoc = workspace.EditDocument( True, doc ) ' Open the backend doc in the UI
Call uidoc.GotoField( "ImageView" ) ' Make the ImageView field the focus
Select Case Imagetype ' Select which image type this file is
Case "GIF":
Call uidoc.Import("GIF Image",filename) ' Import the GIF image into the field
Call uidoc.fieldsettext("ImageType", "GIF Image") ' Set the Image type field
Case "JPEG":
Call uidoc.Import("JPEG Image",filename) ' Import the JPEG image into the field
Call uidoc.fieldsettext("ImageType", "JPEG Image") ' Set the Image type field
Case "PNG":
' NB: This will never happen as Notes doesn't import PNG files although it's there if we need it
Call uidoc.Import("PNG Image",filename) ' Import the PNG image into the field
Call uidoc.fieldsettext("ImageType", "PNG Image") ' Set the Image type field
Case "BMP":
Call uidoc.Import("BMP Image",filename) ' Import the BMP image into the field
Call uidoc.fieldsettext("ImageType", "BMP Image") ' Set the Image type field
End Select
Call uidoc.FieldSetText("Filename", filename) ' Set the filename field
uidoc.CollapseAllSections ' Collapse the preview section
uidoc.save ' Save the UI Doc
uidoc.close ' Close the UI Doc
End Forall ' loop through any of the remaining files
End Sub
Gruß
Raimund