4 Replies Latest reply on Dec 7, 2015 11:53 AM by 6StringSling

    Importing Excel Cells into InDeisgn

    6StringSling

      Hello! New to the forum and to scripting InDesign.

       

      Using InDeisgn CS6 and MS Office 2010 in a Windows 7 OS and scripting with VB Script.

       

      What I have is an Excel file that contains columns of data that are serial numbers and activation codes for a clients software. I need to be able to read the data from, say A2:A2 and place it into a text frame. I need to bypass the Excel import options window. I've gone through the scripting tutorial and Scripting Guide and come up with this:

       

      Set myInDesign = CreateObject("InDesign.Application")

      Set myDocument = myIndesign.ActiveDocument

      Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add

      myTextFrame.GeometricBounds = Array("6p", "6p", "24p", "24p")

       

      With myInDesign.ExcelImportPreferences

           .AlignmentStyle = idAlignmentStyleOptions.idSpreadsheet

           .DecimalPlaces = 4

           .PreserveGraphics = False

           .RangeName = "A2:A2"

           .SheetIndex = 1

           .SheetName = "Sheet1"

           .ShowHiddenCells = False

           .TableFormatting = idTableFormattingOptions.idExcelFormattedTable

           .UseTypographersQuotes = True

           .ViewName = ""

      End With

       

      myTextFrame.InsertionPoints.Item(-1).Place "C:\MyExcelFile.xlsx"

       

      What is happening is that the entire Excel file is being placed, not just cell A2. It's as if the Excel import options dialog is being surpressed but the With block of code isn't being applied. What am I missing?