In which forum did you post your question?
When did you post your question?
Can you send me a link to your question?
I can not find your question on OOo Forum. I did not search long or
hard, but I did indeed search.
I do not know how the routine works in Word, but the following will set
the URL attribute
Sub SetURLLink
Dim oSels
Dim oSel
Dim i As Integer
Dim s$
oSels = ThisComponent.getCurrentController().getSelection()
For i = 0 To oSels.getCount() - 1
oSel = oSels.getByIndex(i)
If oSel.supportsService("com.sun.star.text.TextRange") Then
s = oSel.getString()
If Len(s) > 0 Then
REM Set them as you desire
'oSel.HyperLinkName =
oSel.HyperLinkTarget = s
oSel.HyperLinkURL = s
End If
End If
Next
End Sub
If the selected text is not already in URL format, then you may need to
modify the portion that sets the URL such as by setting it to "http:///"
& s.
HTH
RBL wrote:
Hi all,
I'm trying to write a macro that will allow me to select text, press
Ctrl+K, and convert the text into a hyperlink (as MSFT Word does).
Here's the code I have so far. I want to assign the
HyperlinkAttributes.Text that appears in the Format | Character |
Hyperlink dialog to args1(0).Value. Can someone tell me the object
property name I can use to do this assignment?
I am also looking for (without success) a clean and simple example of
OOo macro code that puts and gets text data from the clipboard.
I posted this to the OOo Forums, but tthose forums seem dead?
Thanks!
sub FormatCharacterHyperlink
rem
----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem
----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")
rem
----------------------------------------------------------------------
dim args1(4) as new com.sun.star.beans.PropertyValue
args1(0).Name = "HyperlinkAttributes.URL"
args1(0).Value = WANT TO ASSIGN SELECTED TEXT TO THIS ELEMENT
args1(1).Name = "HyperlinkAttributes.Target"
args1(1).Value = ""
args1(2).Name = "HyperlinkAttributes.Name"
args1(2).Value = ""
args1(3).Name = "HyperlinkAttributes.VisitedFormat"
args1(3).Value = "Visited Internet Link"
args1(4).Name = "HyperlinkAttributes.UnvisitedFormat"
args1(4).Value = "Internet link"
dispatcher.executeDispatch(document, ".uno:HyperlinkAttributes", "",
0, args1())
end sub
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
Andrew Pitonyak
My Macro Document: http://www.pitonyak.org/AndrewMacro.odt
My Book: http://www.hentzenwerke.com/catalog/oome.htm
Info: http://www.pitonyak.org/oo.php
See Also: http://documentation.openoffice.org/HOW_TO/index.html
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]