Hallo zusammen,
ich habe ein Feld "Link"(bisher normales Textfeld), das mit Pfadinformation vom Windowsexplorer gefüttert wird. Funktioniert auch soweit.
Jetzt soll das ganze aber keine einfache Textzeile sein, sondern als Link Hotspot auftauchen, damit die Textzeile nicht kopiert werden muss, sondern direkt angewählt werden kann.
Ich hab' mich schon durchs Forum und durch die Hilfe zum Thema Hotspottext gelesen, aber komme irgendwie nicht weiter.
Das Feld "Link" habe ich mittlerweile zum richtext Feld gemacht.
Wenn ich den Debugger laufen lasse, sehe ich auch daß das Feld "Link" gefüllt ist. Bei der Zeile set rti kommt dann ein type mismach.... Rich Text Feld Problem????
Die Teile die mit rt zu tun haben, habe ich aus der Hilfe herausgenommen und versucht anzupassen.
Wäre für einen Tipp dankbar, wie so etwas umsetzen kann.
Sub Click(Source As Button)
'Opens a Browse Folders Dialog Box that displays the
'directories in your computer
Dim lpIDList As Long ' Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
Dim doc As NotesDocument
Dim notesitem As NotesItem
Dim item As notesitem
Dim session As New NotesSession
Dim ws As New notesuiworkspace
Dim db As notesdatabase
Dim uidoc As notesuidocument
Dim docunid As String
Dim rti As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtlink As NotesRichTextDoclink
Set uidoc = ws.currentDocument
Set doc = uidoc.Document
szTitle = "Click on a directory path "
' Text to appear in the the gray area under the title bar
' telling you what to do
tBrowseInfo.hWndOwner = 0
tBrowseInfo.lpszTitle = lstrcat(szTitle, "")
tBrowseInfo.ulFlags = 2000
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, Instr(sBuffer, Chr(0)) - 1)
Set item = doc.ReplaceItemValue ("Link",sbuffer)
Call doc.Save(True, True)
End If
Set rti = doc.GetItemValue("Link")(0) --> hier kommt Fehler Type Mismatch
Set rtnav = rti.CreateNavigator
Call rtnav.FindFirstElement(RTELEM_TYPE_DOCLINK)
Set rtlink = rtnav.GetElement
If Link <> "" Then
rtlink.HotSpotText = Link
Call doc.Save(True, False)
End If
End Sub
upps....
Dafür brauchst Du doch ein "GetFirstItem". Das steht aber auch in der Hilfe ...
Jetzt kommt er immerhin einen Schritt weiter und füllt mit rti mit dem richtigen Wert aber bei der zeile bekomme ich nun die Meldung Position is not valid.
Im Debugger sehe ich auch nichts das er rtnav vorher setzt...
Set rtlink = rtnav.GetElement
Ich habs noch mal mit einem alten atnotes Beitrag verglichen, die Reihenfolge sollte doch eigentlich stimmen ?
http://atnotes.de/index.php/topic,40310.0.html (http://atnotes.de/index.php/topic,40310.0.html)
Du solltest Dir Dein Gesamtkonstrukt überdenken.
Genau aus diesem Grund habe ich hier das im Forum gepostet. Ich schüttel mir keine Scripte so aus dem Ärmel, da ich vielleicht ein oder zwei mal im Jahr kleine Programmierungen zu machen habe und da bin ich ganz dankbar, wenn vielleicht der ein oder andere im Internet mir einen Tipp bezüglich Umsetzung geben kann.
Nochmal zu meinem Problem....
ich habe ein Feld "Link"(bisher normales Textfeld), das mit Pfadinformation vom Windowsexplorer gefüttert wird. Funktioniert auch soweit.
Jetzt soll das ganze aber keine einfache Textzeile sein, sondern als Link Hotspot auftauchen, damit die Textzeile nicht kopiert werden muss, sondern direkt angewählt werden kann.
......
Wäre für einen Tipp dankbar, wie so etwas umsetzen kann.
Das ganze ist in einer modifizierten !Help! eingebunden. Hier gibt es einen Button "Select Location", hinter diesem ist mein Script hinterlegt. Mit diesem Script soll das Feld "Link" gefüllt werden. Das Script stammt von Eknori aus einem ähnlichen Thema. Soweit so gut. Das ganze soll aber kein einfaches Textfeld sein (so wie es ursprünglich war), sondern als Link anwählbar sein, damit die Textzeile nicht herauskopiert werden muss... in Explorer eingefügt werden muss usw.
Ich habs im ersten Versuch über die create link hotspot db versucht, aber wieder umgestellt, da hier ein File explizit ausgewählt wurde und kein Folder:
Sub Initialize
'Created by John Buoro - (C) Copyright 2002
'13/07/2002 - Code created.
'16/07/2002 - Version 1.0 released.
'10/09/2002 - Removed Kill statement for Notes.Net.
Dim workspace As New NotesUIWorkspace
Dim uidoc As NotesUIDocument
Dim filename As String
Dim TempFileName As String
'Select the file.
n$ = String$(1024, " ")
f$ = "All Files|*.*|Acrobat Files|*.PDF|Excel Documents|*.XLS|Word Documents|*.DOC|PowerPoint Presentations|*.PPT|PowerPoint Slides|*.PPS|"
ret% = NEMGetFile( 0, n$, f$, "Create File Link Hotspot")
If ret% = 0 Then Exit Sub
filename = Fulltrim(n$)
'Get the working document.
Set uidoc = workspace.CurrentDocument
'Clear the link field.
Call uidoc.FieldSetText( "Link", "" )
'Construct the html code.
Call uidoc.FieldSetText( "HTML", "<html><a href=""file:\\" + filename + """>" + filename + "</a></html>" )
s = uidoc.FieldGetText( "HTML" )
'Write the html code to a temp file.
fileNum% = Freefile()
TempFileName$ = "c:\LinkHotspotCreator.htm"
Open TempFileName$ For Output As fileNum%
Print #fileNum%, s
Close fileNum%
'Import the html file into a rich text field.
uidoc.GotoField( "Link" )
Call uidoc.Import("HTML File",TempFileName$)
'Copy to clipboard.
Call uidoc.GoToField( "Link" )
Call uidoc.SelectAll
Call uidoc.Copy
Messagebox "You can now paste your link into any richtext field.", 0 + 64, "Create File Link Hotspot"
'Clean up.
'Kill TempFileName$
'Call uidoc.Close
End Sub
Aber ich werde jetzt hier noch einmal ansetzen.
Mit dem RTF Problem habe ich verstanden, habs mir schon fast gedacht...
Wenn es noch eine einfachere Möglichkeit gibt, wäre ich dankbar, wenn Ihr mir das irgendwie mitteilt.
Hab jetzt beide Scripte zu einem zusammengefasst und in einen Agenten gepackt, der über den Button gestartet wird.
Da ich auch kein ausgewiesener Experte bin und vieles mal eben gehen soll, mache ich so:
Es funktioniert so wie gefordert, wie es halt manchmal so ist... da geht es mir wie Dir Markus..
Sub Initialize
Dim uidoc As NotesUIDocument
Dim TempFileName As String
Dim lpIDList As Long ' Declare Varibles
Dim sBuffer As String
Dim szTitle As String
Dim tBrowseInfo As BrowseInfo
Dim db As notesdatabase
Dim docunid As String
Dim item As NotesItem
Dim session As New NotesSession
Dim ws As New notesuiworkspace
Set uidoc = ws.currentDocument
Set doc = uidoc.Document
'Select the file.
szTitle = "Click on a directory path "
' Text to appear in the the gray area under the title bar
' telling you what to do
tBrowseInfo.hWndOwner = 0
tBrowseInfo.lpszTitle = lstrcat(szTitle, "")
tBrowseInfo.ulFlags = 2000
lpIDList = SHBrowseForFolder(tBrowseInfo)
If (lpIDList) Then
sBuffer = Space(MAX_PATH)
SHGetPathFromIDList lpIDList, sBuffer
sBuffer = Left(sBuffer, Instr(sBuffer, Chr(0)) - 1)
filename = Fulltrim(sbuffer)
Call doc.Save(True, True)
End If
'Get the working document.
uidoc.EditMode = True
'Clear the link field.
Call uidoc.FieldSetText( "Link", "" )
'Construct the html code.
Call uidoc.FieldSetText( "HTML", "<html><a href=""file:\\" & filename & """>" & filename & "</a></html>" )
s = uidoc.FieldGetText( "HTML" )
'Write the html code to a temp file.
fileNum% = Freefile()
TempFileName$ = "c:\LinkHotspotCreator.htm"
Open TempFileName$ For Output As fileNum%
Print #fileNum%, s
Close fileNum%
'Import the html file into a rich text field.
uidoc.GotoField( "Link" )
Call uidoc.Import("HTML File",TempFileName$)
'Copy to clipboard.
Call uidoc.GoToField( "Link" )
Call uidoc.SelectAll
Call uidoc.Copy
Messagebox "The informations have been added to the design data", 0 + 64, "Create File Link Hotspot"
'Clean up.
'Kill TempFileName$
'Call uidoc.Close
End Sub
Sollte das ganze noch einfacher gehen, baue ich auch gerne noch einmal um ;)