我想在Indesign CS3 VB.NET脚本中对文本帧进行分组。它适用于Indesign 2.0,但与Indesign CS3不起作用。这是我的代码:

Dim myDoc As InDesign.Document = Nothing
Dim myGroup As InDesign.Group = Nothing
Dim myObjectList(2)

myObjectList.SetValue(myOuterTextFrame, 0)
myObjectList.SetValue(myInnerTextFrame, 1)
myObjectList.SetValue(myContentTextFrame, 2)

myGroup = myDoc.Groups.Add(myObjectList) 

获取错误“无法施放type'system.Object []''type'Indesign.Objects'的对象。

有帮助吗?

解决方案 3

我在Indesign脚本样本中找到了答案 - 霓虹灯样本脚本提供了分组示例

其他提示

我知道您很久以前就要求了这个,所以我主要是为了将来的搜索回答。我还没有找到一种完全管理的方法来使用.NET框架并相信我,我已经搜索了它。我尝试了一百万种不同的演员,子分类,反思,您可以命名。最终最终起作用的是JavaScript。以下是采用Indesign.document对象和两个或多个代表Indesign Inte ID的整数的方法。然后,它创建了一些JavaScript并使Indesign执行它。最后,它返回从这些对象创建的Indesign.group。

Public Function GroupObjects(ByVal indesignDocument As InDesign.Document, ByVal ParamArray objectIds() As Integer) As InDesign.Group
    'Sanity checks
    If indesignDocument Is Nothing Then Throw New ArgumentNullException("indesignDocument")
    If objectIds Is Nothing OrElse objectIds.Count < 2 Then Throw New ArgumentException("You must pass at least 2 object ids")

    'We'll assign a unique label to the group that we create in JavaScript so that we can find it in managed code later
    Dim GID = Guid.NewGuid().ToString()

    'Create the JavaScript
    Dim Buf As New StringBuilder()
    Buf.AppendLine("var items = new Array();")
    For Each ID In objectIds
        Buf.AppendFormat("items.push(app.activeWindow.activePage.pageItems.itemByID({0}));", ID)
        Buf.AppendLine()
    Next
    Buf.AppendLine("var g = app.activeWindow.activePage.groups.add(items);")
    Buf.AppendFormat("g.label='{0}';", GID)

    Dim IA = indesignDocument.Parent
    IA.DoScript(Buf.ToString(), InDesign.idScriptLanguage.idJavascript)

    'Loop through all document groups looking for the object with the label created above
    For Each G As InDesign.Group In indesignDocument.Groups
        If Not String.IsNullOrWhiteSpace(G.Label) AndAlso G.Label = GID Then Return G
    Next
    Return Nothing
End Function

要在代码中使用它:

Dim MyGroup = GroupObjects(myOuterTextFrame, myInnerTextFrame, myContentTextFrame)

这个对我有用:

        Type type = Type.GetTypeFromProgID("InDesign.Application");
        Host = (InDesign.Application)Activator.CreateInstance(type);

        InDesign.Objects o = Host.CreateCollection();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top