9 Replies Latest reply on Jan 24, 2011 1:44 PM by elsgoud

    inDesign Noob needs help, please.

    LANcutus

      I'm completely new to inDesign, have to have a VB .NET 2008 app up and running by Friday that will merge a data file with an indesign CS4 document\template (?), then export to a PDF.

       

      Any pointers would be most appreciated. Like, to begin with, what file to bring in as a reference that will expose the inDesign API's?

       

       

      Thanks in advance for your assistance!

        • 1. Re: inDesign Noob needs help, please.
          Kasyan Servetsky Level 5

          Here is a data merge example — it was written and  and tested in VB6:

              Set myFSO = CreateObject("Scripting.FileSystemObject")
              Dim myInDesign As InDesign.Application
              Dim myDoc As InDesign.Document
              Set myInDesign = CreateObject("InDesign.Application.CS3")
              Set myDoc = myInDesign.ActiveDocument
              Set myDataSource = myFSO.GetFile("C:\DataMerge\DataMergeExample.txt")
              myDoc.DataMergeProperties.SelectDataSource (myDataSource)
              myDoc.DataMergeProperties.MergeRecords

           

          Export to PDF-file example:

          myDoc.Export idExportFormat.idPDFType, "c:\myTestDocument.pdf", False, "[Press Quality]"

           

          what file to bring in as a reference that will expose the inDesign API's?

          In VB6 it's called Object Browser

          • 2. Re: inDesign Noob needs help, please.
            LANcutus Level 1

            Thanks for the reply. I have a question though...where is the existing document\template name specified that the text file is to be merged with? I see activedocument but that sounds like inDesign is running with a document already open...this will not be the case.  I think you've given me the keys to what I need to do.

             

             

            Also, I still do not know what file to add to the project references to access the inDesign objects. Does your VB6 program list any imports?

             

            Anyone else have any input for me?

             

            Thanks

            • 3. Re: inDesign Noob needs help, please.
              Kasyan Servetsky Level 5

              You can store indd-files to be processed in a specific folder, then make the script to loop through all the files:

               

                  ' Open a file

                  myFilePath = "C:\DataMerge\DataMergeExample.indd"

                  Set myDoc = myInDesign.Open(myFilePath)

               

                  ' Call data merge function

               

                  ' And finally close without saving

                  myDoc.Close (idSaveOptions.idNo)

              • 4. Re: inDesign Noob needs help, please.
                Kasyan Servetsky Level 5

                Also, I still do not know what file to add to the project references to access the inDesign objects. Does your VB6 program list any imports?

                In VB6 I go to Project > References... and turn on Adobe InDesign CS3 Type Library, I think in VB .NET 2008 should be something similar. If library is not found, choose Browse... button and find it in the application folder.

                • 5. Re: inDesign Noob needs help, please.
                  LANcutus Level 1

                  I found a doc somewhere that described using the VBS function within office, I went to add the reference like it said, I actually found the CS4 type library but when I tried to add it I got "error loading dll".

                   

                  Back in VS2008 I don't see any CS4 type library listed. I clicked browse, went to the application folder but there are a lot of dll's in there...none of them named "Adobe CS4 type library".

                   

                   

                   

                  ****UPDATE******

                   

                    OK after actually starting inDesign I now find the elusive CS4 type library file under COM that I can add as a reference! Now on to utilizing your sample code.

                  • 6. Re: inDesign Noob needs help, please.
                    Kasyan Servetsky Level 5

                    The library name is not "Adobe CS4 type library" — it has some other name, I don't remember which exactly, because I read about it long ago.

                    Since I don't have VS2008 I can't help you with it. I just opened MS Office's 2003 VB editor, the reference is available there too.

                    • 7. Re: inDesign Noob needs help, please.
                      LANcutus Level 1

                      Ok, code is working..somewhat. The myDoc.close doesn't seem to be working. I say that because an inDesign lock file is being created and not released (.IDLK). I have to manually delete this file to complete the pdf writing.  My quick and dirty test code is below, do you see anthing wrong?

                       

                      Imports InDesign, System.IO

                       

                      Public Class Form1

                          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

                            

                              Dim myInDesign As InDesign.Application
                              Dim myDoc As InDesign.Document

                       

                              'load inDesign if not already running
                              myInDesign = CreateObject("InDesign.Application.CS4")

                       

                              'setup document name to be merged
                              Dim myfilepath As String
                              myfilepath = "C:\jbtest.indd"

                       

                              'open the document
                              myDoc = myInDesign.Open(myfilepath)

                       

                              'set datasource for merge
                              myDoc.DataMergeProperties.SelectDataSource("C:\jb.txt")

                       

                              'Call data merge function
                              myDoc.DataMergeProperties.MergeRecords()

                       

                              'export to pdf
                              myDoc = myInDesign.ActiveDocument
                              myDoc.Export(idExportFormat.idPDFType, "c:\myTestDocument.pdf", False, "[Press Quality]")

                       

                              'And finally close without saving
                              myDoc.Close(idSaveOptions.idNo)

                       

                          End Sub
                      End Class

                      • 8. Re: inDesign Noob needs help, please.
                        LANcutus Level 1

                        Thanks for your jelp Kasyan, I have figured it out...see my latest working mockup code below.

                         

                        Imports InDesign, System.IO

                         

                        Public Class Form1

                            Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

                                Me.Cursor = Cursors.WaitCursor

                         

                                Dim myInDesign As InDesign.Application
                                Dim myDoc, myMergedDoc As InDesign.Document

                         

                                'load inDesign if not already running
                                myInDesign = CreateObject("InDesign.Application.CS4")

                         

                                'setup document name to be merged
                                Dim myfilepath As String
                                myfilepath = "C:\jbtest.indd"

                         

                                'open the document
                                myDoc = myInDesign.Open(myfilepath)

                         

                                'set datasource for merge
                                myDoc.DataMergeProperties.SelectDataSource("C:\jb.txt")

                         

                                'Call data merge function
                                myDoc.DataMergeProperties.MergeRecords()

                         

                                'merge creates a new active document, get the new name
                                myMergedDoc = myInDesign.ActiveDocument

                         

                                'export the new document with merged text to pdf
                                myMergedDoc.Export(idExportFormat.idPDFType, "c:\myTestDocument.pdf", False, "[High Quality Print]")

                         

                                'close the new doc without saving
                                myMergedDoc.Close(idSaveOptions.idNo)

                         

                                'now the original doc is the active doc so close it
                                myDoc.Close(idSaveOptions.idNo)

                                Button1.Text = "done "
                                Me.Cursor = Cursors.Default

                         

                            End Sub
                        End Class

                        • 9. Re: inDesign Noob needs help, please.
                          elsgoud

                          Hi

                           

                          I am doing the same thing to convert INDD to PDF. But my Indd file displaying the popup "Update Links". I wanted to supress that popup.how can we do this.

                          I am doing automation. WIndows app will open the indd file and convert PDF and close the Opened document.

                           

                          Please suggest me how to suppress Popups...

                           

                          Thanks,

                          Sree