Article View: adobe.scripting.indesign
Article #8573Re: I know this should be simple, but how do I get the selected text?
From: StevenLmas
Date: Wed, 11 Oct 2006 14:26
Date: Wed, 11 Oct 2006 14:26
38 lines
1594 bytes
1594 bytes
This seems highly inefficient, but it looks like it works...
Function GetSelection(Optional whichCase As Integer) As String
Dim inD As InDesign.Application
Dim iDoc As InDesign.Document
Dim iWord As InDesign.Word
Dim sWords As String
Set inD = CreateObject("InDesign.Application.CS2")
Set iSel = inD.Selection
If TypeName(iSel.Item(1)) = "Text" Then
For Each iWord In iSel.Item(1).Words
sWords = sWords & " " & iWord.Contents
Next iWord
Else
MsgBox "You must have one or more characters of text selected", vbExclamation, "Get Selection"
GetSelection = ""
End If
Select Case whichCase
Case 0 'As is
GetSelection = sWords
Case 1 'UPPER CASE
GetSelection = UCase(sWords)
Case 2 'lower case
GetSelection = LCase(sWords)
Case Else
GetSelection = sWords
End Select
Set inD = Nothing
Set iDoc = Nothing
Set iWord = Nothing
Set iSel = Nothing
End Function
Technical Details
Message-ID:
<3bc1efe9.0@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossingReferences:
<3bc1efe9.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,70d1d670d6ed3210 X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII-7-bit From: StevenLmas@adobeforums.com Newsgroups: adobe.scripting.indesign Subject: Re: I know this should be simple, but how do I get the selected text? Message-ID: <3bc1efe9.0@webcrossing.la2eafNXanI> Date: Wed, 11 Oct 2006 07:26:59 -0700 References: <3bc1efe9.-1@webcrossing.la2eafNXanI> Lines: 39 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.germany.com!news.ecp.fr!news.stben.net!webcrossing