Article View: adobe.scripting.indesign
Article #20573Re: VB: Copy text without formatting
From: Olav Kvern
Date: Wed, 26 Jun 2002 19:12
Date: Wed, 26 Jun 2002 19:12
33 lines
2353 bytes
2353 bytes
Keith--
Here's one way to do it:
Rem Copy without formatting
Dim myInDesign As InDesign.Application
Set myInDesign = CreateObject("InDesign.Application.2.0")
Set mySelection = myInDesign.Selection
If mySelection.Count > 0 Then
����If TypeName(mySelection.Item(1)) = "Text" Then
��������Set myText = mySelection.Item(1)
��������myString = myText.TextContents
��������MsgBox "Select some text, or click an insertion point in a text frame, and then click OK to paste the unformatted text."
��������myInDesign.Activate
��������Set mySelection = myInDesign.Selection
��������Select Case TypeName(mySelection.Item(1))
������������Case "InsertionPoint"
����������������mySelection.Item(1).TextContents = myString
������������Case "Text"
����������������mySelection.Item(1).TextContents = ""
����������������myInDesign.Selection.Item(1).TextContents = myString
��������End Select
����End If
End If
Select some formatted text, then run the script. The script will display a message box. Select some text, or click the Text tool in a text frame, then click OK in the message box.
It strikes me that we could also do this via some direct VB clipboard manipulation (i.e., VB.Clipboard.SetText myString) but this gets around the problem of InDesign setting the Clipboard when you switch into/out of the application.
Thanks,
Ole
Technical Details
Message-ID:
<ef95865.0@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef95865.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,727ae8a458e8e9ea X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-06-26 12:39:40 PST From: "Olav Kvern" <okvern@adobe.com> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-08!supernews.com!newsfeed.news2me.com!newsfeed.freenet.de!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: VB: Copy text without formatting Message-ID: <ef95865.0@WebX.aaQKaf7vad4> Date: Wed, 26 Jun 2002 12:12:15 -0700 References: <ef95865.-1@WebX.aaQKaf7vad4> Lines: 39 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit