1 Reply Latest reply on Sep 10, 2009 3:36 AM by ldb68

    Place EXCEL table

    ldb68

      Hi. I use this code to test excel table import in Indesign.

      The table is imported correctly but without any preferences.

      Any help?

       

      REM LOAD FILE FROM FILE
      file_indd= "C:\test.indd"

       

      REM from samples

      Function myGetBounds(myDocument, myPage)
        idRightHand = &H72677468
        idLeftHand = &H6C667468
        idSingleSided = &H75736578

       

        myPageWidth = myDocument.documentPreferences.pageWidth
        myPageHeight = myDocument.documentPreferences.pageHeight
        If myPage.Side = idLeftHand Then
          myX2 = myPage.marginPreferences.Left
          myX1 = myPage.marginPreferences.Right
        Else
          myX1 = myPage.marginPreferences.Left
          myX2 = myPage.marginPreferences.Right
        End If
        myX2 = myPageWidth - myX2
        myY1 = myPage.marginPreferences.Top
        myY2 = myPageHeight - myPage.marginPreferences.bottom
        myGetBounds = Array(myY1, myX1, myY2, myX2)
      End Function

       


      REM OPEN Indesign
      Set myInDesign = CreateObject("InDesign.Application.CS3")
      myInDesign.ScriptPreferences.UserInteractionLevel = &H654E7672
      myInDesign.ScriptPreferences.EnableRedraw = False              

       

      REM LOA Ddocument

      Set myDocument = myInDesign.Open( file_indd , true)
      REM Set myDocument = myInDesign.ActiveDocument

       

      Rem Sets the Excel import filter preferences.
      With myInDesign.ExcelImportPreferences
          Rem alignmentStyle property can be:
          idSpreadsheet = &H73707273
          idLeftAlign = &H6C656674
          idRightAlign = &H72676874
          idCenterAlign= &H63656E74
          REM
          AlignmentStyle = idSpreadsheet
          DecimalPlaces = 4
          PreserveGraphics = False
          REM Enter the range you want to import as "start cell:end cell".
          RangeName = "A1:B3"
          SheetIndex = 1
          SheetName = ""
          ShowHiddenCells = False
          REM tableFormatting property can be:
          idExcelFormattedTable = &H786C4654
          idExcelUnformattedTable = &H786C5554
          idExcelUnformattedTabbedText = &H78555454
          REM
          TableFormatting = idExcelFormattedTable
          UseTypographersQuotes = True
          ViewName = ""
      End With                                          

       

      REM Create a text frame.
      Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
      myTextFrame.geometricBounds = myGetBounds(myDocument, myDocument.Pages.Item(1))

       

      REM PLACE EXCEL FILE
      myTextFrame.Place("C:\test.xls")