Article View: adobe.scripting.indesign
Article #20329Re: Detach Inline Graphics - VB-ID1.5.2
From: Nelson Ribeiro
Date: Fri, 19 Jul 2002 11:42
Date: Fri, 19 Jul 2002 11:42
128 lines
5240 bytes
5240 bytes
Peter
First of all, thank you very much. With that help I
managed to make it work exactly as expected. I also
apologize for not having the script snippet posted. I had my
script in such a mess with all my tries that I didn't have
the time to do that.
Well, although it worked, I was not happy with the idea
of not having Option Explicit on and not using the Dim
statements. I know Olav doesn't love them much ( as in 01:15am
Jan 16, 2002 Pacific (#6) <http://www.adobeforums.com/cgi-bin/webx?14@@.ef61b40/5> The fact is that I do like the
help it provides. It has been very useful to me.
So I tried (again) to use a variable declared as Object
to hold the inline. When I tried, I found that sometimes it
worked, some not. When it didn't' work I had an error of "invalid
parameter" in the line myInDesign.Select myCoisa
. It was a long time to figure out that the fact affecting
this was that the active window showed a spread while the
objects being moved were in another spread! If I put the
spread where the objects were, in the active window (making
a page down in InDesign and clicking on the corresponding
pasteboard, for example) when in debug mode in VB, then it
all went well.
After this, I included some code to make the current
spread (the one being worked on) the active spread. And now
I can work with my Dim and Option Explicit.
I included my code to detach inlines, based on a
paragraph style. When not using Option Explicit I
used For Each myInline In myParag.Inlines and myInDesign.Select
myInline as in your suggestion. They are commented out.
Private Sub ForumDescolar_Click()
Dim myWindow As InDesign.Window
Dim myTextFrame As InDesign.TextFrame
Dim myPage As InDesign.Page
Dim mySpread As InDesign.Spread
Dim myParagraphStyle As InDesign.ParaStyle
Dim myParag As InDesign.Paragraph
Dim myStory As InDesign.story
Dim myN
Dim mySelection As Variant
Dim myNumParagraphs As Integer
Dim myCountP As Integer
Dim myCountPFeitos As Integer
Dim myCoisa As Object
Dim myPosition As Variant
myN = 0
Set myInDesign = CreateObject("InDesign.Application.1.5")
Set myWindow = myInDesign.ActiveWindow
Rem Achar a story da selec��o
MsgBox "Click on the Story text and click OK"
Set mySelection = myInDesign.Selection
If TypeName(mySelection) = "Text" Then
����Set myStory = mySelection.Parent.ParentStory
Else
����Exit Sub
End If
myInDesign.Activate
Set myParagraphs = myStory.Paragraphs
myNumParagraphs = myParagraphs.Count
For myCountP = 1 To myNumParagraphs
����Set myParag = myParagraphs(myCountP)
����myN = myN + 1
If TypeName(myParag.ParagraphStyle) = "ParaStyle" Then
��������Set myParagraphStyle = myParag.ParagraphStyle
��������If Left(myParagraphStyle.StyleName, 6) = "Espa�o" Then
������������Rem Position the active window on the current spread
������������Set mySpread = myParag.Parent.Parent.Parent
������������myWindow.ActiveSpread = mySpread
'For Each myInline In myParag.Inlines
������������For Each myCoisa In myParag.Inlines
����������������myPosition = myParag.Inlines(1).GeometricBounds
��������������� 'myInDesign.Select myInline
����������������myInDesign.Select myCoisa
����������������myInDesign.Cut
����������������myInDesign.Paste
����������������myInDesign.Selection.Move Array(myPosition(1), myPosition(0))
����������������myCountPFeitos = myCountPFeitos + 1
������������Next
��������End If
����End If
Next
myInDesign.Selection = Nothing
Debug.Print Time
MsgBox "Detached " & myCountPFeitos & " Graphic frames in" & _
��������myN & " checks", vbInformation, "Detaching"
End Sub
What I would like to know is why do I get "invalid
parameter" when selecting an inline graphic just
because the active spread doesn't show the spread where
object being selected is.
Anyone?
Thanks,
Nelson Ribeiro
Technical Details
Message-ID:
<ef9af83.1@WebX.aaQKaf7vad4>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!canoe.uoregon.edu!logbridge.uoregon.edu!newsfeed.esat.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebXReferences:
<ef9af83.-1@WebX.aaQKaf7vad4>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: f939a,e3b1a92e901f8531 X-Google-Attributes: gidf939a,public X-Google-ArrivalTime: 2002-07-19 05:23:16 PST From: "Nelson Ribeiro" <nelson@ptinovacao.pt> Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!canoe.uoregon.edu!logbridge.uoregon.edu!newsfeed.esat.net!lnewspeer01.lnd.ops.eu.uu.net!emea.uu.net!newsfeed01.sul.t-online.de!t-online.de!WebX Newsgroups: adobe.scripting.indesign Subject: Re: Detach Inline Graphics - VB-ID1.5.2 Message-ID: <ef9af83.1@WebX.aaQKaf7vad4> Date: Fri, 19 Jul 2002 04:42:37 -0700 References: <ef9af83.-1@WebX.aaQKaf7vad4> Lines: 120 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit