0 Replies Latest reply on Oct 24, 2014 4:15 AM by IndesignScriptingKuman

    Passing object as parameter throws compile error - Type Mismatch

    IndesignScriptingKuman Level 1

      While using VBA, When passing object as parameter throws compile error.

       

      Sub layoutAnArticle()


      Dim myWordDoc As String

      Dim myDocument As InDesign.Document

      Dim myStory As InDesign.Story

      Dim myTextFrame As InDesign.TextFrame

      Dim myPage As InDesign.Page

       

      Set myInDesign = CreateObject("InDesign.Application.CS6")

      Set myDocument = myInDesign.Open(workingDirectory + workingFile)

      Set myDocument = myInDesign.Documents.Item(1)

      Set myPage = myDocument.Pages.Item(1)

      myboundsarray = myGetBounds(myDocument, myPage)

      Set myTextFrame = myPage.TextFrames.Add

      myTextFrame.GeometricBounds = myboundsarray

      myTextFrame.Place ("ScriptingTryWordDoc.docx")

      Set myStory = myTextFrame.ParentStory

       

      formatStoryText (myStory)

       

      end sub

       

      Sub formatStoryText(ByRef subStory As InDesign.Story)

       

      myInDesign.FindGrepPreferences = idNothingEnum.idNothing

      myInDesign.ChangeGrepPreferences = idNothingEnum.idNothing

       

      myInDesign.FindGrepPreferences.FindWhat = "  +"

      myInDesign.ChangeGrepPreferences.ChangeTo = " "

      subStory.ChangeGrep

       

      myInDesign.FindGrepPreferences.FindWhat = " *\r[ \r]*"

      myInDesign.ChangeGrepPreferences.ChangeTo = "\r"

      subStory.ChangeGrep

       

      myInDesign.FindGrepPreferences = idNothingEnum.idNothing

      myInDesign.ChangeGrepPreferences = idNothingEnum.idNothing

       

      ' end of formatStoryText

      End Sub

       

      While trying to run layoutAnArticle, it gives "Compile error: Type mismatch..." at the calling point of formatStoryText.