This content has been marked as final. Show 14 replies
Your problem starts here:
Set DepthMarker = myDocument.Textframes.Item
...which item? Item takes either an integer (the index of the item) or a string (the contents of the label property, if any).
Next, however, is that you should be more specific about *where* the text frame is in the document. What page or spread is it on? Let's say that the frame "DepthMarker" is on page 1:
Set DepthMarker = myDocument.Pages.Item(1).TextFrames.Item(1)
If there's only one frame on that page, you're in great shape. If not, you need to come up with some way to differentiate one frame from another. Script labels are a great way to do this. Let's say you've used the Script Label panel to add the label "DepthMarker" to the relevant frame on page 1, and added the label "WarningText" to another frame. In that case, you'd use something like this:
Set DepthMarker = myDocument.Pages.Item(1).TextFrames.Item("DepthMarker")(0)
Set WarningText = myDocument.Pages.Item(1).TextFrames.Item("WarningText")(0)
...When you use a string to refer to a page item by its label, InDesign returns an array, so you need to get the first item in the array (assuming that there's only one page item on the page with that label).
Hope this makes sense! I'm typing it off the top of my head because I have to go speak at a conference tomorrow and am short on time--but it should get you pointed in the right direction.
But there is 4 frames on one page and I labeled them with the script label, and I tried your advice but it still doesn't work.
Can you please tell me the how I could use, these commands with 4 frames all on one page as I tried, (see below) but it didnt work??
Set DepthMarker = myDocument.Pages.Item(1).Textframes.Item("DepthMarker")(0)
DepthMarker.Contents = PoolSignScheduleDepth
Set WarningText = myDocument.Pages.Item(1).Textframes.Item("WarningText")(0)
WarningText.Contents = PoolSignScheduleWarningText
Set WarningSymbol = myDocument.Pages.Item(1).Graphicframes.Item("WarningSymbol")(0)
WarningSymbol.Contents = PoolSignScheduleWarningFile
Set RegText = myDocument.Pages.Item(1).Textframes.Item("RegText")(0)
And please, NO SHOUTING :)
Thanks Simon that actually worked for the Text Frames, but not the graphic frame.
Got any ideas how I can fix this graphic frame??
Set WarningSymbol = myDocument.Pages.Item(1).Graphicframes.Item("WarningSymbol")
WarningSymbol.Contents = PoolSignScheduleWarningFile
>var myItem = app.documents.selection;
alert("Page item type: " + myItem.constructor.name);
If you get "Rectangle" as the type, then you'll probably need to change the line to read:
>Set WarningSymbol = myDocument.Pages.Item(1).Rectangles.Item("WarningSymbol")
As far as I know, you can't set the contents of a graphic frame to a picture file, you have to 'place' it. So the command would be something like:
Please excuse me if I've got the actual VBScript snippets wrong. But hopefully this will point you in the right direction.
Thanks Simon, that actually worked and pasted the picture onto the frame.
But I am still getting an error message, 'The requested member of the collection does not exist'
Source: C:\Program Files\Adobe\Adobe InDesign CS3\InDesign.exe
How do I make it go away?
I really appreciate your support thanks again Simon & Olav
I'm glad that I could help, but unfortunately I have to admit that I'm out of my depth with this one. I don't know about VBScript error messages so I'm unsure as to what it could be.
Do you have the ability for line-by-line code execution? Can you see exactly what line this is happening on?
If not, can you edit the script to just do one or two operations at a time and keep adding until the error message appears?
Set RegText = myDocument.Pages.Item(1).Textframes.Item("RegText")
RegText.Contents = PoolSignScheduleRegText
Set RegSymbol =
It says line 34 char 2 so either one of these commands, but I have no idea why that error message is coming up as the commands look right, and its weird because the script generates the document,
Do you know why that error message is coming up??
Just out of curiosity, is the 'Set RegSymbol = myDocument...' set on one line? Does whitespace matter with VBScript? If there is a return after the equal sign in that line then remove it and see if this gets rid of the error.
To be honest, I'm reaching here, so if any body has some more knowledge of VBScript and they can help Robert, I think his problem is almost solved.
Yes it is set on one line, I just couldn't fit all that text on one line.
I have no idea why that error message is appearing??
The script is creating pool signs and there are four frames and some of the templates only use 2 frames, could it be when these templates are called that are not using all 4 frames, are contributing to this error??
When the script is passing data to 4 frames to templates that only have 2 frames, it wont allow it.
Is there a command that can allow this??
I tested it and that was the reason, I don't want to create multiple scripts is there a command that can allow this exemption to disregard the additional frames if its calling templates not using all 4 frames??
Case closed I used an If statement, and the script is working without any bugs.
Thank you Simon and Olav and all this Adobe Forum,
I am very proud to be using the Adobe CS suit
Glad it's working for you--sorry I was out of town and couldn't help get it figured out. Thanks, Simon for stepping in!
Just a note about VBScript/JS differences--overall, the models are the same. Capitalization is different (it matters in JS, but VBScript doesn't care), and the JS "remove" method is "delete" in VBScript. The only other thing is that JS arrays and collections start at 0; in VBScript, collections start at 1 and arrays start at 0.