🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #16603

Re: [VB] Updating link fails

#16603
From: Brian W. McMahon
Date: Fri, 15 Aug 2003 05:26
89 lines
4040 bytes
Hi, Ole.

I want to create a method of compiling an InDesign document from a number of Word documents. The Word documents will be changing as they are edited, so I want to automate incorporating the changes, either by recreating the InDesign document or by updating the links to the Word files.

At the moment I am trying to work out the basics. The first section of code (I am using VBA in Word) creates an InDesign document, puts a text box on the first page, places a Word file into the text box and saves the file. This seems to work properly.

'open InDesign
Set myInDesign = CreateObject("InDesign.Application.2.0")
'
'create a new document
Set myDocument = myInDesign.Documents.Add
'
'set document preferences
Set myDocPreferences = myDocument.DocumentPreferences
With myDocPreferences
    .PageHeight = 297
    .PageWidth = 210
    .PageOrientation = idPortrait
    .NumberOfPages = 1
End With
'
'set margins on master pages
Set myMasterPageLeft = myDocument.MasterSpreads.Item(1).Pages.Item(1)
Set myMasterPageRight = myDocument.MasterSpreads.Item(1).Pages.Item(2)
With myMasterPageLeft.MarginPreferences
    .ColumnCount = 1
    .ColumnGutter = 10
    .MarginTop = 30
    .MarginBottom = 20
    .MarginLeft = 20
    .MarginRight = 20
End With
'
With myMasterPageRight.MarginPreferences
    .ColumnCount = 1
    .ColumnGutter = 10
    .MarginTop = 30
    .MarginBottom = 20
    .MarginLeft = 20
    .MarginRight = 20
End With
'
'put text frame on page 1
Set myTextFrame = myDocument.Pages.Item(1).TextFrames.Add
'
'size text frame to margins
'get the margin preferences of the page
myX1 = myMasterPageRight.MarginPreferences.MarginLeft
myY1 = myMasterPageRight.MarginPreferences.MarginTop
myX2 = myDocPreferences.PageWidth - myMasterPageRight.MarginPreferences.MarginRight
myY2 = myDocPreferences.PageHeight - myMasterPageRight.MarginPreferences.MarginBottom
'resize the text frame to match the margins
myDocument.Pages.Item(1).TextFrames.Item(1).GeometricBounds = Array(myY1, myX1, myY2, myX2)
'
'place the Word item file into the text box
itemPath = "H:\InDesign scripting\TestDocs"
itemFile = "CSTest001b.doc"
itemToPlace = itemPath & Application.PathSeparator & itemFile
myTextFrame.Place itemToPlace
'
'save the InDesign file
myDocument.SaveAs itemPath & Application.PathSeparator & "testsave01.indd"
'
'export as pdf
myDocument.Export idExportPDF, itemPath & Application.PathSeparator & "testsave01.pdf"
'

Then I go into the Word document, change the text, save it and close it. The next section of code is meant to update the link to the Word file. However, I get the runtime error on the myLink.Update line. When I go back into InDesign, it has picked up the need for an update, and I can update the link manually and that works properly.

itemPath = "H:\InDesign scripting\TestDocs"
testDoc = "testsave01.indd"

'open InDesign
Set myInDesign = CreateObject("InDesign.Application.2.0")
'
'open test document
Set myDocuments = myInDesign.Documents
myDocuments.Open itemPath & Application.PathSeparator & testDoc
Set myDocument = myInDesign.Documents.Item(1)
'
Set myLinks = myDocument.Links
Set myLink = myLinks.Item(1)
'
myLink.Update
'

Thanks. Any thoughts you have would be appreciated.

Brian McMahon
Technical Details
Message-ID: <1dea498d.3@WebX.la2eafNXanI>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1dea498d.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,a93e33b37eeb6af0
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-08-14 22:37:37 PST
From: "Brian W. McMahon" <b.mcmahon@etc.unsw.edu.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-09!supernews.com!news-out.visi.com!petbe.visi.com!eusc.inter.net!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: [VB] Updating link fails
Message-ID: <1dea498d.3@WebX.la2eafNXanI>
Date: Thu, 14 Aug 2003 22:26:45 -0700
References: <1dea498d.-1@WebX.la2eafNXanI>
Lines: 104
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit