Loop through all the items in a collection
I need to loop through all the elements of a collection in a VB.NET program that uses the InDesign API. For example, I want to loop through all the pasta spread masters in a document. Here is my sample code:
Dim I As Integer = 0
Var MyApp as InDesign.Application = Nothing
Var MyDoc as InDesign.Document = Nothing
Var MyPage as InDesign.Page = Nothing
MyApp = CType (Activator.CreateInstance (Type.GetTypeFromProgID ("InDesign.Application"), True), InDesign.Application)
MyDoc = CType (MyApp.Documents.Add (False), InDesign.Document)
With MyDoc
With. DocumentPreferences
. PageHeight = "8.5I".
. PageWidth = "5.5i."
Ends with
With. ViewPreferences
. HorizontalMeasurementUnits = InDesign.idMeasurementUnits.idPoints
. VerticalMeasurementUnits = InDesign.idMeasurementUnits.idPoints
Ends with
If. MasterSpreads.Count > 0 Then
For I = 0 To. MasterSpreads.Count - 1
Dim ThisMasterSpread As InDesign.MasterSpread = CType (.) MasterSpreads.Item (I), InDesign.MasterSpread)
Next I
End If
Ends with
When it runs, I get an error on the last Dim statement which defines ThisMasterSpread. It highlights. MasterSpreads.Item (I) and gives the following error:
COMException was unhandled: the Member required to the collection does not exist.
How I managed to loop over all the pasta spread masters?
Thank you!
A lot of trial and error, I discovered the answer to my own question: the Collections are 1-based, not 0-based. My statement
For I = 0 To. MasterSpreads.Count - 1
should be
For I = 1 To. MasterSpreads.Count
Tags: InDesign
Similar Questions
-
To loop through all the variables on an image
Hello. I am trying to write a method to save the State of the game that I do. I am able to loop through all the clips and get their existing frameworks, but is it possible to loop through all the variables on the current frame (without knowing their names) and put them in a table?
Thanks 4 any help
trigger2160Thanks for the help. A container object is just what I wanted, even though I knew not u can do. my variables are not accessible directly so I managed to change the way they were stored easily without negative effects for the rest of the game. Now I can also save and load the State of the game which entered 4 will facilitate 4 me to test.
trigger2160
-
Hello
Need your contributions on the approach to implement a work using dbms_scheduler.
We have about 2000 drawings. Each schema has a package with 2 procedures.
The requirement is to create a single job in SYS that loop over each schema and run the procedures specific to a time (once a day) and send a notification by e-mail on success or failure.
Working script:
BEGIN
dbms_scheduler.create_job (job_name = > 'LOAD_EACH_SCHEMA_AUDIT_DATA',)
job_type = > 'PLSQL_BLOCK ',.
job_action = > ' BEGIN sys.p_loadaudit;
END;',
start_date = > systimestamp,
repeat_interval = > ' FREQ = MINUTELY; RANGE = 1',
number_of_arguments = > 0,
enabled = > true,
Comments = > "Use repeat interval is every five minutes");
END;
/
Note: to test the end I put him repeat interval to carefully.
Use of procedure must be running:
Procedure sys.p_loadaudit:
CREATE OR REPLACE
PROCEDURE p_loadaudit
AS
v_count NUMBER: = 0;
lv_error_message VARCHAR2 (4000);
vstmt VARCHAR2 (4000);
BEGIN
I'm IN
(SELECT username FROM dba_users WHERE username LIKE '% ABCFIRM')
)
LOOP
vstmt: = "begin" | i.UserName | '. pkg_audit_info.p_load_coa; end;';
EXECUTE immediate vstmt;
vstmt: = "begin" | i.UserName | '. pkg_audit_info.p_load_am; end;';
EXECUTE immediate vstmt;
END LOOP;
EXCEPTION
WHILE OTHERS THEN
lv_error_message: = ' error in procedure p_loadaudit: ' | SQLCODE. "- ERROR -" | SUBSTR)
SQLERRM, 1, 300). '*' || dbms_utility.format_error_backtrace;
raise_application_error(-20002,lv_error_message);
END p_loadaudit;
/
Example of a scheme: SCHEMA_01
create or replace
PACKAGE pkg_audit_info
AS
CursorType type
IS
REF
CURSOR;
PROCEDURE p_load_COA;
PROCEDURE p_load_AM;
END pkg_audit_info;
/
create or replace
Pkg_audit_info body PACKAGE
AS
PROCEDURE p_load_COA
AS
BEGIN
INSERT INTO TABLE1();
EXCEPTION
WHILE OTHERS THEN
lv_error_message: = ' error in procedure pkg_audit_info.p_load_COA: ' | SQLCODE
|| "- ERROR -" | SUBSTR (SQLERRM, 1, 300). '*' || dbms_utility.format_error_backtrace;
RAISE_application_error(-20002,lv_error_message);
END p_load_COA;
PROCEDURE p_load_AM
AS
BEGIN
INSERT INTO TABLE2();
EXCEPTION
WHILE OTHERS THEN
lv_error_message: = ' error in procedure pkg_audit_info.p_load_AM: ' | SQLCODE.
"- ERROR -" | SUBSTR (SQLERRM, 1, 300). '*' || dbms_utility.format_error_backtrace;
RAISE_application_error(-20002,lv_error_message);
END p_load_AM;
END pkg_audit_info;
/
Table1 and table1 exist in schema_01.
All 2000 patterns have same package.procedures.
For security reasons, I removed the actual code.
I was able to complete the task successfully. However, when a scheme procedure (SCHEMA_01.pkg_audit_info.p_load_COA) throws an exception, the job fails, and any transaction is rolled back.
Is it possible to loop through each schema and run the corresponding procedures. Even if the exception occurs, it must restore only for this scheme and continue other patterns in the loop?
Please let me know if there is a better way to do this. Is the way I'm handling exceptions in the work or the correct procedure?
Thank you
Hello
RAISE_APPLICATION_ERROR will cause the program to exit to the appellant, even if you put it inside a block in the loop, so the statement RAISE or RAISE_APPLICATION_ERROR must be placed in your procedures 'pkg_audit_info.p_load_AM' and 'pkg_audit_info.p_load_coa '. In this way, you can use a block inside the loop and the error in the log.
I'm IN
(SELECT username FROM dba_users WHERE username LIKE '% ABCFIRM')
)
LOOP
BEGIN
vstmt: = "begin" | i.UserName | '. pkg_audit_info.p_load_coa; end;';
EXECUTE immediate vstmt;
vstmt: = "begin" | i.UserName | '. pkg_audit_info.p_load_am; end;';
EXECUTE immediate vstmt;
EXCEPTION
WHILE OTHERS THEN
--> Set the error in a table of otherwise custom event log you won't know what happened for this scheme: don't forget the user name
END;
END LOOP;
-
To loop through all the values of a variable in ODI
Hi all
I have a table table1 with date fields in this
Thus, the table will be something like
Date_column
January 1, 2014
JANUARY 4, 2014
JANUARY 5, 2014.
I have a variable var1 declared in my project, which can take the values in this table.
So the definition of the updating of the variable var1 is
Select from table1 date_column.
Now for each of these dates, I have to run a script, the script takes value of var1 date as a parameter.
This must be run in a loop so that all the dates in the table may be covered.
Could you please how this can be achieved in a package in ODI.
Be able to find the solution for this: thanks to all the other post that helped me to get the solution.
-
To loop through all the leaves in numbers
How would browse all sheets in a file of numbers with AppleScript? (From here on, I'm wanting to rename each worksheet of the value of a cell on the sheet, but I think I found the part). Thank you very much.
I'm not at home so I can't give you the exact code, and I assume that you already have some knowledge of script. If this can help:
In applescript, you can refer to the leaves of number. that is to say the sheet 1
so you might as likely get something like this works:
Repeat with j from 1 to (number of sheets)
say map j
Hope this helps even a little.
Jason
-
I downloaded Itunes 12.3.3 and now I tunes does not recognize my Ipad or Iphone. I went through all the procedures and just uninstall and reinstall. Please fix 12.3.3.Thanks.
-
How can I return to my start page without scrolling through all the links I have open?
In previous versions of Ff, I could go to a menu drop down and go back to my original home page (or another that I had opened) without having to scroll through all the links open back. I can't find a way to do it in 4.0.
You can get the menu drop-down by clicking on the previous/next buttons or now the left key pressed until the list is displayed.
If you want the drop-down arrow, you can add it with the add-on of dropmarker rear - https://addons.mozilla.org/firefox/addon/backforward-dropmarker
-
my sound keeps disappearing. I go through all the help and support the steps but still no sound. the volume control is all grey and says no audio device found. but the Device Manager indicates that all is well. What is the problem that I continue to have?
Hello
1. the troubleshooting steps are you referring?
2. don't you make changes on the computer before this problem?The following article might be useful.
No sound in Windows
http://Windows.Microsoft.com/en-us/Windows/help/no-sound-in-Windows -
When you turn on the computer, it goes through all the departures start loading windows xp then again again and again...
Hi Keryn_Jansen,
1. did you of recent changes on the computer?
2. you receive an error message?
3 when was the last time it was working fine?
Check if you can start the computer in safe mode or from the last good known Configuration.
Advanced Troubleshooting for General startup problems in Windows XP
http://support.Microsoft.com/kb/308041
How to fix a computer that does not start
http://Windows.Microsoft.com/en-us/Windows-XP/help/Setup/how-to-fix-computer-that-will-not-start
-
I have xp pro I have activated telephone went through all the steps said active windows computing took me to the login screen, but when I try to connect, it tells me that I need to activate windows so I click on activate the itr tells me that windows is already activated, then takes me in the newspaper and did the same thing
To delete the message you are already enabled, you can force the activation on reboot. If the wpa.dbl and wpa.bak are damaged, they can cause a problem.
Restart in 'Safe Mode '.
Rename wpa.dbl and wpa.bak files located in the the\Windows\system32 folder
Now, the message must be deleted, and you can now re-enable. TaurArian [MVP] 2005-2010 - Update Services -
I DON'T KNOW WHY BUT MY MESSAGES IN MY INBOX ARE ALL MUDDLED UP.
USED TO SEE THE MOST RECENT AT THE TOP NOW, I TUNED THROUGH ALL THE EMAILS TO FIND THE RECEIPT TODAY'S MAIL? Help, please.Steve is of course correct. What mail client do you have?
-
get all the items you selected / checked
Hello
How all the items selected in a list that can be read?
I need get all items (enabled) in the list and fill a vector...
I get not all selected items, I only get the element on which is currently...
Help, please
Hello
Exactly what I wanted to say, you need to implement this thing on yourself.
I will try to explain the step hope it will help
(1) create an array whose length is the same as listField.Intialize this table by 0 which means initially no element is selected.
(2) each position in the table represent the listField position.
(3) to each selection on listField change the corresponding value in table 1, for example if you select 2 point listField change the value in position 2 in table 1, if you select again the same option to new swtich tha value to 0.
(4) Finally, when you want to extract the value of the selected item in the listfield, select all the table position with the value 1.
I tried to explain the hope it will help you.
-
Download all the contents of a collection
Hello
Is there a way to download all the contents of a collection at a time? Instead of browse an article for download start.
Thank you
New option added two weeks ago allows it.
Is a collection level option, it defined in the collection properties: 'Allow the user to save the collection of their device' - characteristic expression is "explicit downloads".
Read more here: Digital Publishing Solution help | What's new in this version of DPS 2015
-
Where can I find my product key to 24 digits for Adobe CS6 Design and Web Premium? I went through all the normal download and a 19-digit serial number! I had to buy a new hard drive from Apple, and when they were installed, I lost my programs. Help, please! Ive tried to download them for two days!
http://helpx.Adobe.com/x-productkb/global/redemption-code-help.html
http://helpx.Adobe.com/x-productkb/global/find-serial-number.html
Mylenium
-
I went through all the steps to download the trial version of Adobe Photoshop elements 13. It is said download completed, but nothing happened then prompting to launch the program. I checked the finder (MAC OS) and could not find. Don't have Adobe download wizard. How to open and run the program?
Jediii please see Photoshop elements 13 full download. What to do next? where this topic was just discussed.
Maybe you are looking for
-
Hello everyone, I am new to the community. My new IPad pro application for password, I have donot remember. As a new tab without any file, I tried to restore it to factory settings as detailed in the already available relevant help topic. But, even a
-
How to import bookmarks settings on computer that has been wiped with no backup.
I had to "Refresh" the system of windows due to some problems. Without realizing that I needed to make a backup of my files Firefox to retrieve my profile later, I couldn't. I'm looking to see how I can return all my settings and bookmarks with this
-
Windows could not start on Satellite L510
HI :) I'm not very tech savvy, I've only had my laptop a month. And yesterday, when I turned it back on I got this message... Windows could not start. A recent hardware or software change might be the cause. To solve the problem: Insert your windows
-
Bug in Windows 7,8,10
Hello I found a bug (feat) on Microsoft Windows 7 and 8, and it's still there in the latest version of Windows 10. I want to share this problem with Microsoft Corporation and to win the prize of $100,000 that Microsoft gives to anyone who finds the d
-
password does not not on KB Article number: 888111
I downloaded the hd audio bus from Microsoft software. (The KB Article number: 888111) She needed a password to launch (via the e-mail I received) and he gave me two passwords the first was expired I tried the second password and it does not work. In