Home

Crystal Ball Macro Calls

image

Contents

1. a 229 41 e A In O aan 229 CE Sa ome 230 EB STOLE MU te oic CREDO I as tie tao tea boe dede CIO M UE Vat CoRbu ac ideo eee Re ian 231 CMI tt Geduld RENI EROS CM DAC OS RO ORDNUNG CRI dU A E kaa RR GRE i 231 lar p 232 CB TWO DSU SHOW sid is ai Godd bd Ree een en GO Ve OPEM eas HE ee ae 236 UB IMODSMUlStO D P RM 236 OB ers ipie AAA RR 241 Introduction This chapter defines all currently available Crystal Ball Developer Kit macro calls subroutines and functions When calls are compared with those in Crystal Ball 2000 5 5 5 the comparisons usually apply to other 2000 x 5 x versions For an index with summaries and tables of calls grouped by functionality see Chapter 2 Note Commands that change Crystal Ball data cells will not run ifthe cellor the entire worksheet is write protected For example two such commands are CB Simulation and CB CellPrefsND You can use CB WorksheetProtection to unprotect and reprotect worksheets CB AboutBox This subroutine displays the About Crystal Ball dialog with information about Crystal Ball CB AboutBox Example This example opens the About Crystal Ball dialog CB AboutBox CB AlertOnArgumentError 42 This subroutine displays a message when the value ofa subroutine or function argument differs from what i
2. ads 209 inopi o EOS As a aa DN Installing Crystal Ball Runtime A Mr 266 Crystal Ball Runtime Licensing B quitemebis i242292 cR ERR RERYU RARE RARE PAS 267 Appendix A Using the OptQuest Developer Kit ee eee ooo 269 About the OptQuest Developer Kit Pee Ried PS reed or er oer sa 269 TEENS TIERE AAA b nc d e e AAA 269 What This Kit Includes ea ara dr ida 270 What You Will Need ds ads dad za 270 OpiQuest Developer Kit Use and SUCHE eaa rad ea or HERR EORR REOR 270 ize A e pol rol ac MW 270 OptQuest Developer Kit Namespace p nasi dace e bac bk REG PR CPG PRG 271 Important OptQuest Classes buds baud bns EUN NS EE pcs 271 Developing Optimization MAA 274 Development Environment ARA A A RR EROR RUN 274 Development Resources ass 274 LONE Un a AA eee ANS ee eee ees ROCA 277 User defined Event Macros for ptimizations lt 4i6css cnc rr 279 User defined Event Macro Names 2 64045 60 0i4se4 5050 epica prie 279 Using Events in VBA RE aida hes phei piss bed dos sdas 280 Event Signatures eii IRA AA Tere 281 Constraints and Macros E auntie cu ab o ao ende 283 Global Macros ads Appendix B Using the Predictor Developer Kit xb dax E Rcs dolus ios Ec ador Du Rcx Cee sal 285 About the Predictor Developer Fal
3. P 230 Contents xiii CB Startup Example ee Yes s 281 LN s DEL i el EMEN 4M CB StopMultiSimul aas aaa vd dera E E ia 231 CB StopMultiSimul Related Calls Eta eee ee er Re eee cere 231 A A A ee aedi wb da 231 AA AMA 232 CI TNABdDSE Dated A card AAA 232 CB TrendPrefsND Ei ere M ee Bods nm os ree ss 232 CE A AAA 235 AA rara price 235 CB TwoDSimulation be redd us bes sortate TTEN S24 A CB IDU EXPERTA 236 CB TwoDSimulation Related Cile aid 236 CB TDS ABANDO A Vaden AA ARAS dae w eee RRR Dawes 236 LB TwoDSimulationND Example 1 2 2 4 x rt rro ape 3400s eden rr E COTA Ll UND EZ cose icke dee ok A ARA RES 240 CB TwoDSimulationND Related Calls 4424222222245 249 9 rra 240 CB WorksheetProtection Pius PS Brus oe bus 25 xus Re bus TES 241 CH WerksheetProtection Example 45 224duk er diari ra Oe 242 CB WorksheetProiechon Tale desene ox eo ROC AR ARAGAO 242 CB WorksheetProtection Example3 ror Sake or 242 Chapter 4 Changes from Previous Versions 0 0 00 ccc cece IRI 245 Introduction 2444 d a eee pss xd 245 Le CE ENS CIE TRENT MT 245 Added in Crystal Dall 1 2 A 246 Not Included in This Version ECTS ia bus SEG yes a ET 247 a EHE CUR AA 249 E ia A bx d dat ROG og RUE Se case Se ROB E RC ug adas 249 CB AatoDownshilt is uec Xe OR o ROCA A ORC ACE AA AAA A 24
4. Parameter VBA Data Type Value Description DisplayWhileRunning Variant True or False Used only when Optional DisplayAuto is set to True True for this parameter opens the forecast window at the start of a simulation False opens the forecast window at the end of a simulation The default is True Obsolete_WindowSize n a n a This parameter formerly Optional WindowSi ze is obsolete and is no longer available for use However if you use one of the following optional parameters you need to leave a space for it set off by a comma LSL Optional Variant A numeric value double a Enters a lower specification limit string representing a cell for the forecast reference such as B1 or cbParmUndefined USL Optional Variant A numeric value double a Enters an upper specification string representing a cell limit for the forecast reference such as B1 or cbParmUndefined Target Optional Variant A numeric value double a Enters a target value for the string representing a cell reference such as B1 or cbParmUndefined forecast CB DefineForeND Example This example defines a new forecast in cell C9 with the name of Profit and no unit label The forecast chart window is set to appear automatically when the simulation starts Range C9 Select CB DefineForeND Profit True True CB DefineForeND Related Calls Name CB DefineFore Description Defines forecas
5. EN 187 HMM c coc a uu EL ene D MM M E M ME EUER ONE e uoo med IM ME CM MEME IRE MM COL ODERTIBRO eis iei t ER O S DB Postage a ds o TEMO E A add cba dd uta ER dads da eT 191 CB ResetND 192 CB Restore emule ad A A O A NCE RHRPTBIS o A Ra E onda had A A A een CB RunPrefsND n o r ipid eer is LOD CB RuntimeMode 1 ceo eee qeria m iens abend mm ara cute sient 200 CRSA RESUS soii icon winced qusc pida al PAETE E AE I T HT 201 CB Saveresul Dra RN NICE NONIS 202 CO ria n rU 202 GB caue PIE oues nce adito Eres Rea tau aM One Rap kac adieu A O D Sel PR o A naa CORR A nian Kad aun nid usa aque d Es NEU al Eslida 208 CBS ic is ii id si a CESSIT RONE vo cacas caca a O O ds a me tr er re 209 COPs ere Mie iaa A 210 CB SensPrelsMD cr Dm A 210 E CAO RR RUM nuda EUM dee IE irc unco Ir foc teer rU 214 CB SetCBWorkbookPriority ssssssse ret resi lol dee dela 215 CE eI Dep Vl mis ninski vac cid nicas qui siis 216 CB SetExcel200 7ForegroundMode Ed a dia asii ica 218 AA ES O P I m OA EDO A und eet UR EMEN M D MEC CM ern en Tem eM EE EE A Per C E a UE T ERU E d EG TER Ga ER Ld ER Udo en Ce E ac RE CE DA Ca E Ca Ll O Cert E EE Den iau a Pe acd Ur GERE Cbr ERE Dae ed ub a RP ee ee A ge naaa pao aca Du dad arre Viga cria daa 226 GI ote Cc One eR en ree are eet eee ree
6. CB GetAssumPercent Example 1 This example runs a simulation of 1000 trials and then puts the values for every fifth percentile into an array called Percents In a macro you can enter CB Simulation 1000 Dim Percents 19 As Double For i 1 To 19 TT Besmet 143 CB CheckData Percents i Next i CB GetAssumPercent Range C9 i 5 CB GetAssumPercent Example 2 This example enters the value at the 50th percentile of the assumption distribution in cell B3 In a worksheet cell you can enter CB GetAssumPercentFN B3 50 CB GetAssumPercent Related Calls Name Description CB EnumAssum Enumerates assumption cells for all open workbooks CB GetAssum Retrieves information for a specific assumption cell CB GetForePercent Returns percentiles for forecast cells CB GetBatchFitOption This function returns specified settings made by CB BatchFitND or the Batch Fit tool Table 88 CB GetBatchFitOption Returned Data Type Returned Value Returned Data Type The specified Batch Fit settings Variant Table 89 CB GetBatchFitOption Parameters Required Integer Parameter Required VBA Data Type Table Index Required Integer Table 90 Valuel Optional Variant Table 91 Value2 Optional Variant Table 92 Table 90 CB GetBatchFitOption Index Parameter Required Integer Named Constant Value Index Value Description cbBftInputRange 1 Returns a string with the addr
7. 185 GCBMscroBesuliDenll Related Call 4424 eoo HEURE RECO RC 186 COMA 186 CB OpenChart Example 1 ARIAS seuss 187 COCA cra da sas 157 Cp Residir Aaa m CE Open Fore cir Ropa ca 187 CB OpenFore Example baa 188 CR Dae BE CU sarro er ira seae ees 188 CB OpenSelection covcrrcrada opor nr dara 188 CB OpenSelection Example bus m TR See e 188 GB Omnbelacaon Related Calle ita id Rs sie 188 CB OpenSensitiv iia dra deta de lao decada de 189 UB Opensenotpe Examples ori AA Cobb MU oia a 189 axe o Calf asd dex De Foe osa or eoe o E 2 c kckesGacs teeters sche teees pees EN REPAS Yd AE TETEA EEN 189 CB OpenTrend Example idque Eee ide qudd T i idque 190 CB OpenTrend Related Calls eus ee bes dis T TOT 190 Ro Paste AAA AAA oc c ce dd a ae e O CB PasteData Example 1 rne 190 CB PasteData Example 2 edd Res bed T ee 191 GB rare ae ESE ua dieque d ec eee RARA RARA doses EN ae Deaed LE AMAS 191 CLASS spare da ed paaddqe uina 191 CB Reset Example beg CAER Sees renee 192 ee Be ri rr AAA L CERAIN Lesen sp epp dodo pd Marae pipe e po dr Bde oup doe eod denos 192 CB ResetND Example ad ide dd ee 192 Ce Ario Cl rar sr Lee o nn 193 CH Restore Rests Exatnple rocircareodtraatpadeke dipadik aip aaae a 193 CB RestoreResults Related Calls bes Seay
8. Named Constant Index Value Description cbParmLocation 12 Location parameter See Table 53 cbParmScale 13 Scale parameter See Table 53 cbParmMode 15 Mode cbParmAlpha 16 Alpha parameter See Table 53 cbParmBeta 17 Beta parameter See Table 53 cbParmShape 18 Shape parameter See Table 53 cbParmRate 19 Rate value See Table 53 cbParmMidpoint 20 Midpoint value See Table 53 cbParmDegFreedom 21 Degrees of freedom value See Table 53 cbParmPercentile 0 Percentile value Add the desired percentile to this parameter for example cbParmPercentile 80 indicates the 80th percentile Note Because there are three alternate parameter sets in addition to percentiles for the lognormal distribution the cbParmRegular named constant cannot be passed to CB DefineAltParms when setting up an alternate parameter set for the lognormal distribution You must explicitly set the parameter set with for example cbParmLogMean and cbParmLogStDev cbParmModeis included to support the extreme value distribution for backward compatibility with Crystal Ball 2000 x 5 x In later versions of Crystal Ball that distribution is replaced with the maximum extreme and minimum extreme distributions cbParmMode is deprecated in this version of Crystal Ball and is obsolete in a future version CB DefineAltParms Example 1 This example defines the assumption in cell B5 as a normal distribution using the mean and standard deviation
9. CB SelectChart This call selects or activates the current operating chart Ifthe specified name is not found an error is thrown Ifa name is not specified for example by passing an empty string as the name and more than one chart of the specified type is found a chooser dialog appears Currently this call only works on current and not restored results Table 154 CB SelectChart Parameters and Values Parameter VBA Data Type Value Description SimChartType Integer cbChtOverlay 1 Specifies the type of chart cbChtScatter 2 you are selecting overlay cbChtSensitiv 3 scatter sensitivity or trend cbChtTrend 4 charts according to the named constant and index values listed in the Value column ChartID String The string ChartlD Indicates the chart to returned from select CB EnumChart or CB CreateChart CB SelectChart Example This example runs a simulation and selects the next overlay chart found in the workbook Because CB EnumChart is used here call CB CheckData CB Simulation 1000 CB CheckData CB SelectChart cbChtOverlay CB EnumChart cbChtOverlay CB SelectChart Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB CreateChart Creates a new chart of the specified type with the optional name if specified 208 Crystal Ball Macro Calls Name Description CB EnumChart Returns the unique n
10. CB SingleStep on page 229 Runs one trial of a simulation changing assumptions once CB StartMultiSimul on page 229 Marks the start of multiple simulations CB Startup on page 230 Loads Crystal Ball into Excel if possible and indicates when Crystal Ball has been successfully opened CB StopMultiSimul on page 231 Marks the end of multiple simulations CB TrendPrefs on page 231 Opens the Trend Preferences dialog for the selected trend chart CB TrendPrefsND on page 232 Sets preferences for the specified trend chart Alphabetic List of Crystal Ball Macro Calls 31 Name CB TwoDSimulation on page 236 Description Launches the 2D Simulation tool CB TwoDSimulationND on page 236 Runs the 2D Simulation tool without showing dialogs CB WorksheetProtection on page 241 Enables and disables worksheet protection for the active worksheet Functions For Use in Excel Models The following Crystal Ball functions are also available as spreadsheet functions for use in Excel spreadsheet models Table 2 Functions For Use in Excel Models Name Description CB GetAssumFN Retrieves information for a specific assumption cell See CB GetAssum on page 140 CB GetAssumPercentFN Returns the value corresponding to a percentile for an assumption cell See CB GetAssumPercent on page 143 CB GetCertaintyFN Retur
11. ORACLE CRYSTAL BALL FUSION EDITION RELEASE 11 1 1 3 DEVELOPER S GUIDE ORACLE ENTERPRISE PERFORMANCE MANAGEMENT SYSTEM Crystal Ball Developer s Guide 11 1 1 3 Copyright O 1988 2009 Oracle and or its affiliates All rights reserved Authors EPM Information Development Team The Programs which include both the software and documentation contain proprietary information they are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright patent and other intellectual and industrial property laws Reverse engineering disassembly or decompilation ofthe Programs except to the extent required to obtain interoperability with other independently created software or as specified by law is prohibited The information contained in this document is subject to change without notice If you find any problems in the documentation please report them to us in writing This document is not warranted to be error free Except as may be expressly permitted in your license agreement for these Programs no part of these Programs may be reproduced or transmitted in any form or by any means electronic or mechanical for any purpose If the Programs are delivered to the United States Government or anyone licensing or using the Programs on behalf of the United States Government the following notice is applicable U S GOVERNMENT RIGHTS Programs software databases and related document
12. Run Batch Fit CB BatchFitND cbBftRun CB BatchFitND Related Calls Name Description CB BatchFit Launches the Batch Fit tool CB GetBatchFitOption Returns current settings for the Batch Fit tool CB Bootstrap This call launches the Bootstrap tool wizard This tool estimates the reliability accuracy of forecast statistics and other sample data The Bootstrap tool displays a forecast chart of the distributions for each statistic capability metric or percentile and creates a workbook summarizing the data Note Before calling CB Bootstrap reset the simulation CB Bootstrap 55 CB Bootstrap Example This example resets the Crystal Ball simulation and opens the Bootstrap wizard CB ResetND CB Bootstrap CB Bootstrap Related Calls Name Description CB BootstrapND Runs the Bootstrap tool without displaying dialogs CB GetBootstrapOption Returns current settings for the Bootstrap tool CB BootstrapND The Bootstrap tool estimates the reliability accuracy of forecast statistics process capability metrics percentiles and other sample data This call runs the Bootstrap tool and displays results without using a dialog Note Before calling CB BootstrapND reset the Crystal Ball simulation Table 14 CB BootstrapND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 15 Index2 Optional Integer Table 16 Value Optional Variant Table 17
13. CB Simulation 1000 CB Simulation Example 2 This example switches to Normal speed and runs a simulation of 100 000 trials Because of the lengthy number of trials all the time saving options of suppressing forecast windows and minimizing worksheets and Excel are set to True This call does not set a text string to use in the Excel status bar since Excel is minimized during the simulation and any string would never be displayed CB ResetND CB RunPrefsND cbRunMode cbRunNormalSpeed CB Simulation 100000 True True True CB Simulation Related Calls Name Description CB Reset Resets the current simulation after prompting CB ResetND Resets the current simulation without confirmation CB StartMultiSimul Marks the start of multiple simulations CB StopMultiSimul Marks the end of multiple simulations 228 Crystal Ball Macro Calls CB SingleStep This subroutine runs one trial of a simulation changing the assumptions once The simulation must not be running when you use CB SingleStep CB SingleStep Example This example resets any previously run simulation and single steps once runs one trial CB ResetND The above call makes sure the trials begin at 1 CB SingleStep CB SingleStep Related Call Name Description CB Simulation Runs simulation for specified number of iterations CB StartMultiSimul This subroutine enables you to use resources more effectively when running multiple
14. Name Description CB TrendPrefsND Sets preferences for the specified trend chart without using a dialog CB TrendPrefsND The function sets preferences for the selected trend chart Ifmore than one trend chart is defined and no chart is selected this call returns an error Note Before calling CB TrendPrefsND run a simulation Table 181 Parameters for CB TrendPrefsND Parameter VBA Data Type Value Description Index Integer See Table 182 Works with the other parameters to set trend chart preferences Valuel Variant See Table 183 Works with the other parameters to set trend chart preferences Value2 Optional Variant See Table 184 Works with the other parameters to set trend chart preferences Value3 Optional Variant See Table 185 Works with the other parameters to set trend chart preferences Value4 Optional For Index 8 Integer Any integer between O and Sets a fourth certainty 100 inclusive band to display Use this 232 Crystal Ball Macro Calls Parameter VBA Data Type Value Description with Value1 through Value3 Value5 Value6 Value7 All optional Integer Any integer between 0 and 100 inclusive Sets up to three more certainty bands to display Use this with va1ue1 through value4 Table 182 following describes the Index parameter Table 182 CB TrendPrefsND Index Parameter Values Required Integer Named Con
15. CB GetAssumPercent Returns percentile for an assumption cell 142 Crystal Ball Macro Calls Name Description CB GetDecVar Retrieves information for a specific decision variable cell CB GetFore Retrieves information for a specific forecast cell CB GetAssumPercent This function calculates the value of the specified assumption that corresponds to the specified percentile You can call this function from either a subroutine or a worksheet To call this function from a worksheet use the name CB GetAssumPercentFN Note In VBA code always call CB CheckData before calling this function to ensure the latest data values are used Table 86 CB GetAssumPercent Returned Data Type Returned Value Returned Data Type Assumption value that corresponds to the specified percentile Variant The percentile is calculated based on the assumption s distribution Any truncation points are factored into the percentile calculation Note Reversing the percentiles using the cbRunReversePercentile option does not affect the output of this function For more information see CB RunPrefsND on page 195 Table 87 CB GetAssumPercent Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to the desired mption cell In a worksheet B3 assumpuon e Percent Double A number between 0 and Specifies the percentile for 100 which you want the assumption value
16. CB RestoreResults This subroutine opens the Restore Results dialog so you can restore previously saved simulation results any results data and charts created but not necessarily open at the time the results are saved You can restore any number of results files at one time but they must be opened one at a time by calling them with CB RestoreResults You do not need to reset the current simulation before you run this subroutine You can restore results while a simulation is running completed or stopped To run this subroutine you must have a saved cbr file or CB MacroResult returns cbErrRestoreResult CB RestoreResults is similar to CB RestoreRun available in Crystal Ball 2000 5 5 5 However CB RestoreRun and CB RestoreRunND restored an entire simulation saved with CB SaveRun or CB SaveRunND not just the results The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored at a time See the Oracle Crystal Ball User s Guide for more information on saving simulation results CB RestoreResults Example This example automatically opens the Restore Results dialog to restore previously saved simulation results CB RestoreResults CB RestoreResults Related Calls Name Description CB RestoreResultsND Restores simulation results from a file without a dialog CB SaveResults Saves current simulation results data charts and reports using a dialo
17. CB RestoreResultsND Example This example automatically restores the previously saved simulation file saveme cbr CB RestoreResultsND C temp saveme cbr CB RestoreResultsND Related Calls Name Description CB RestoreResults Restores simulation results from a file using a dialog CB SaveResults Saves current simulation results using a dialog CB SaveResultsND Saves current simulation results without a dialog CB RunPrefs This subroutine opens the Run Preferences dialog so you can change simulation settings CB RunPrefs Example This example opens the Run Preferences dialog 194 Crystal Ball Macro Calls CB RunPrefs CB RunPrefs Related Calls Name Description CB GetRunPrefs Returns a run preference setting CB RunPrefsND Changes run preferences settings without a dialog CB RunPrefsND This subroutine sets preferences corresponding to the Run Preferences dialog Any run preferences not explicitly defined default to the current setting in the Run Preferences dialog See the Oracle Crystal Ball User s Guide for more information on setting run preferences Table 147 CB RunPrefsND Parameters Parameter Index VBA Data Type Value See Table 148 Description Works with the Valuel Integer and Value2 parameters to set Crystal Ball run preferences Valuel Variant See Table 149 Works with the Index parameter to set Crystal Ball run preferences V
18. CB OpenFore Opens a forecast chart for the selected cell CB Simulation Runs a Crystal Ball simulation 188 Crystal Ball Macro Calls CB OpenSensitiv This call opens the selected sensitivity chart If no sensitivity charts have been created for a model one is created for the first forecast and opened If more than one chart is found but one is not selected a chooser dialog is displayed Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB OpenSensitiv on page 258 To open a chart of a specific type by its chart ID use CB OpenChart CB OpenChart on page 186 CB OpenSensitiv Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next sensitivity chart in the workbook and then opens it CB Simulation 1000 CB CheckData CB SelectChart cbChtSensitiv CB EnumChart cbChtSensitiv CB OpenSensitiv CB OpenSensitiv Related Calls Name Description CB CloseSensitiv Closes the selected sensitivity chart CB CopySensitiv Copies the selected sensitivity chart to the clipboard CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB OpenTrend This call opens the selected trend chart If no trend charts have been created for a model one is created It i
19. CB SaveResultsND This subroutine automatically saves results data and charts for the current simulation into the file specified by FileName Once you have saved a results file with cbr extension you can use CB RestoreResults or CB RestoreResultsND to open it and restore the results CB SaveResultsND is similar to CB SaveRunND available in Crystal Ball 2000 5 5 5 However CB SaveRunND stored an entire simulation not just the results CB RestoreRun and CB RestoreRunND were used to restore the saved simulation The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored at a time This differs from the current requirements for CB RestoreResults and CB RestoreResultsND discussed beginning in CB RestoreResults on page 193 Table 150 CB SaveResultsND Parameters Parameter VBA Data Type Value Description FileName String A path surrounded by quotes such as C temp sheet2 cbr Points to the results file where simulation results are saved Before running this subroutine run a simulation The simulation must be completed or stopped but not reset See the Oracle Crystal Ball User s Guide for more information on saving simulation results CB SaveResultsND Example This example runs a simulation of 1000 trials and then saves the simulation results to file Saveme cbr CB Simulation 1000 CB SaveResultsND C temp Saveme cbr CB SaveR
20. Column Integer Any number up to 256 Points to the column of the second correlated assumption Row Long Any number up to 64 000 Points to the row of the second correlated assumption CB GetCorrelation Example This example puts the correlation coefficient between G8 and G15 into cell H15 In a macro you can enter CB GetCorrelation 153 CB CheckData Range H15 Value CB GetCorrelation Related Calls CB GetCorrelation Range G8 15 Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB GetAssum Retrieves information for a specific assumption cell CB GetDataAnalysisOption This function returns specified settings made by CB DataAnalysisND or the Data Analysis tool Table 103 CB GetDataAnalysisOption Returned Data Type Returned Value Returned Data Type The specified Data Analysis settings Variant CB GetDataAnalysisOption has one parameter Index which is a required integer See Table 104 for details Table 104 CB GetDataAnalysisOption Index Parameter Required Integer Named Constant Value cbDataAnalysisSelectData VBA Data Type Integer Index Value 2 Description Returns a string with the address of the target forecast in the format workbook sheet A 1 cbDataAnalysisDataOrientation Integer Returns one of two possible values for the data orientation cbDataAnaly
21. on page 91 Runs the Data Analysis tool without displaying dialogs CB DecisionTable on page 96 Launches the Decision Table tool CB DecisionTableND on page 96 Runs the Decision Table tool without displaying dialogs CB DefineAltParms on page 99 Creates or changes an alternate parameter set CB DefineAssum on page 102 Defines or changes assumptions in selected cells with a dialog CB DefineAssumND on page 103 Defines or changes assumptions in selected cells without a dialog CB DefineDecVar on page 108 Defines or changes a decision variable in a selected cell using a dialog CB DefineDecVarND on page 109 Defines or changes a decision variable in a selected cell without a dialog CB DefineFore on page 112 Defines a forecast in a selected cell using a dialog CB DefineForeND on page 113 Defines a forecast in a selected cell without a dialog 28 Crystal Ball Developer Kit Overview Name CB DeleteChart on page 115 Description Deletes a chart of the specified type and chart ID CB EnumAssum on page 115 Enumerates assumption cells for all open workbooks CB EnumChart on page 117 Returns the unique name of the next chart of the specified type CB EnumCorrelation on page 118 Enumerates correlated assumptions and correlation values for all open workbooks CB EnumDecVar on pag
22. CB DataAnalysis Description Launches the Data Analysis tool CB DataAnalysisND Runs the Data Analysis tool without displaying dialogs CB GetDecisionTableOption This function returns specified settings made by CB DecisionTableND or the Decision Table tool Table 105 CB GetDecisionTableOption Returned Data Type Returned Value Returned Data Type The specified Decision Table settings Variant Table 106 CB GetDecisionTableOption Parameters Parameter Required VBA Data Type Table Index Required Integer Table 107 Index2 Optional Integer Table 108 156 Crystal Ball Macro Calls Table 107 CB GetDecisionTableOption Index Parameter Required Integer Named Constant Value cbDecGetTarget Index Value Description Returns a string with the address of the target forecast in the format workbook sheet A 1 cbDecGetDecVar Returns a string with the address of the selected decision variable in the format workbook sheet A 1 Must be used with Index2 cbDecVar1 or cbDecVar2 to indicate which decision variable s address to return cbDecSimOption Used with Index2 to return the number of test values for the specified decision variable orthe maximum number of trials for the simulation cbDecForeOption Returns the current forecast chart display setting 1 Show Forecasts As Defined set with cbDecShowDefinedFore 2 Show Only Tar
23. CB GetBatchFitOption Example 1 ados 148 GB GetBatchFtOphon Example 2 o iocpeppe cas Es EA 148 CB GetBatchFitOption Related Call arar 148 CB GetBootstrapOption ere adei ye 148 CB GetBootstrapOption ae Lim HAIL A mp duis 150 CR GetBootstrapOption Example 2 oa car beatae a RA T CH GetBaotstrapOption Related Calls i245 aues dae ca hu Y ARRA 150 CB GetCBAutoLoad ee er cease ds er 151 CAE AMO Example ers ere AA 151 CH GeCBAntoLoad Related Calls 2252222222424 da 151 CB GetCertainty TEP bas TEE ds bes sipi ee EA lt 131 CEG erman ERPE 8 ee bo hn aida IA AAA EY dw dee ere dE CB GeCertanty Exaupled a cusan bea x Ro Sareea AAA sve n CD GetCertainty Related Calls iia IN KK RR QATAR RAE 153 pit wo A I ER e pla ri A edi 153 CB GeCordatios Related Calls crirsacrininsar vr A 154 CB GetDataAnalysisOption 254 ads eS 154 pnma Doo A 156 CB GetDataAnalysisOption Exainple2 occiso tk ado Ke ROCA ORG ER OCA a 156 CB GetDataAnalysisOption Related Calls i244 T 156 INN DO ODER 2 44 9 rr E EORR CR OE o e pee deed 156 CB OR DeddonTablelipton Example 1222 acte hd rv 158 CB GetDecisionTableOption Related Calls 3 64 uadaedqedasesesd Ear ae d rre 158 CB GetDecVar Kus bes Rx ws bes seas er F bwi avs lt 158 CUAL RARA AAA SHES tee GB GelDecVar Related Calls
24. Continuing For best results examine all of the sample code If something isn t clear open CB Com Devkit chm and search for the object in question From there experiment with your own code You can begin by copying OptDevKitRuntimeSample xls and modifying its code in different ways Error Handling The OptQuest Developer Kit handles the same error codes as CB MacroResult in the Crystal Ball Developer Kit However the OptQuest Developer Kit can take action when an error occurs when a non 0 error code is generated Error handling statements can take the form of On Error GoTo or On Error Resume Next For example consider the following code sample from OptDevKitRuntimeSample xls on page 276 On Error GoTo ErrorHandling This means that when an error condition occurs the ErrorHandling code is called Then ShowError is called and a series of messages describe the detected error For details look at the code in OptDevKitRuntimeSample xls and search for ShowError Also look up CB MacroResult and CB MacroResultDetail in the Crystal Ball Developer Kit User Manual Accessing OptQuest with the Crystal Ball Developer Kit The object instantiation in OptDevKitRuntimeSample xls on page 276 uses the Set New syntax to create objects in the CBCOMDevKit namespace 278 Using the OptQuest Developer Kit Set PortfolioOptSetup New CBCOMDevKit OptSetup Set PortfolioOptRuntime New CBCOMDevKit OptRuntime
25. For Index 4 cbBtsAnalyze cbBtsAnalyzeCapMetrics 3 Analyzes distributions of Integer process capability metrics only available if process capability metrics are activated on the Statistics tab of the Crystal Ball Run Preferences dialog or using the CB RunPrefsND call For Index 5 cbBtsPercent cbBtsPercentTenNinety 1 Specifies the 10th and 90th Integer percentiles For Index b cbBtsPercent cbBtsPercentFiveNinetyFive 2 Specifies the 5th and 95th Integer percentiles For Index 5 cbBtsPercent cbBtsPercentQuartiles 3 Specifies quartiles 25 ile Integer increments from O to 100 inclusive For Index 5 cbBtsPercent cbBtsPercentQuintiles 4 Specifies quintiles 20 ile Integer increments from O to 100 inclusive For Index 5 cbBtsPercent cbBtsPercentDeciles 5 Specifies deciles 10 ile Integer increments from O to 100 inclusive CB BootstrapND 57 Related Value Named Constant Value Index Value Description For Index b cbBtsPercent cbBtsPercenticosatiles 6 Specifies icosatiles 5 ile Integer increments from O to 100 inclusive For Index b cbBtsPercent cbBtsPercentCustom T Defines custom percentiles Integer supplied by an optional Value entry a one dimensional cell range containing percentiles If Value s omitted the default percentiles are 2 5 5 50 95 97 5 For Index 6 cbBtsSample cbBtsNumberSamples 1 Used wi
26. For Index 56 cbRunCapMetricsNormalityThresh Double Any positive value between O and 1 Specifies the p value threshold used for normality testing For Index 57 cbRunCapMetricsNormalCalcOption s Integer Oor1 Determines if the capability metrics should be calculated from the fitted curve or the data if the distribution is not normal O calculate from fitted curve and 1 calculate from data CB RunPrefsND Example This example sets the simulation to use the same sequence of random numbers with an initial seed value of 888 and use Monte Carlo simulation It then runs the simulation of 100 trials CB RunPrefsND 199 CB RunPrefsND cbRunSameRandoms True 888 CB RunPrefsND cbRunSamplingMethod cbSamMonteCarlo CB Simulation 100 CB RunPrefsND Related Calls Name Description CB GetRunPrefs Returns a run preference setting CB RunPrefs Changes run preference settings using a dialog CB RuntimeMode This subroutine turns offthe Crystal Ball toolbar and menus so you can create applications with your own custom interface for novice Crystal Ball users These custom applications can be written with the Crystal Ball Developer Kit to run on Crystal Ball version 7 2 2 or later including 11 x or later You can give users the ability to run reset and single step through simulations by creating your own user interface controls with Visual Basic or VBA that call appropriate Crystal Ball Develo
27. Name Description CB CheckData Checks Crystal Ball data cells for validity initializes variables with dialogs in case of error CB EnumAssum Enumerates assumption cells for all open workbooks CB EnumFore Enumerates forecast cells for all open workbooks CB EnumDecVar Enumerates decision variable cells for all open workbooks CB ClearData This subroutine prompts you to confirm and then erases assumptions decision variables or forecasts from selected cells Any values or formulas in the cells remain The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts Ifthe range contains more than one type of Crystal Ball data a dialog appears and you can select the data types to clear Before you clear data reset the current simulation Note Before calling this subroutine select a cell or cell range containing Crystal Ball data and reset the simulation CB ClearData Example The following lines of code reset the simulation prompt the user to clear any Crystal Ball data in the currently selected cells and then clear the data CB ResetND CB ClearData The cell contents such as a value cell reference or formula remain CB ClearData Related Calls Name Description CB ClearDataND Clears assumptions decision variables and forecasts from selected cells without confirmation CB CopyData Copies Crystal Ball data in the specifie
28. PrefItem Integer cbAssumShowMean 3 Sets whether to display the mean line on the distribution dialog True OnOff boolean True or False n a True turns on the option False turns off the option 44 Crystal Ball Macro Calls Note Prefltem constant cbAssumShowCoordinates 2 is obsolete CB AssumPrefsND Example This example turns off the marker at the distribution mean for the assumption in cell A1 Range A1 Select CB ND cbAssumShowMean False CB AutoDownshift This call specifies whether to automatically downshift to Normal speed when a simulation cannot run in Extreme speed and returns the current setting This setting is global It is in place fortheentire Crystal Ball session The default setting is True which switches automatic downshift on If CB AutoDownshift is set to False and a simulation cannot run in Extreme speed the simulation fails and an error is returned CB MacroResultDetail CB MacroResultDetail on page 184 can return the reason for the failure Note If CB AutoDownshift is not called Crystal Ball acts as if it has been called with the default setting of True That is if a simulation cannot run in Extreme speed it is automatically downshifted to Normal speed and nothing is recorded in the error log because the simulation ran successfully You can test whether a simulation can run in Extreme speed by causing the simulation to fail when it cannot run in Extreme speed To perform the t
29. The subroutines and functions described in the following sections are used to work with Crystal Ball results CB CreateRpt on page 80 CB CreateRptND on page 80 CB ExtractData on page 122 CB ExtractDataND on page 123 CB GetAssum on page 140 CB GetAssumPercent on page 143 CB GetCertainty on page 151 CB GetCorrelation on page 153 CB GetDecVar on page 158 CB GetFore on page 162 CB GetForeData on page 165 CB GetForePercent on page 166 CB GetForeStat on page 167 CB RestoreResults on page 193 Managing Charts 35 e CB RestoreResultsND on page 193 e CB SaveResults on page 201 e CB SaveResultsND on page 202 e CB SetRange on page 223 e CB SimResult on page 226 Setting and Getting Preferences The macro calls in this group can be used to e Set run preferences e Set format preferences e Set chart preferences e Set cell attribute preferences The subroutines and functions described in the following sections are used to set and get preferences e CB AssumPrefsND on page 44 e CB CellPrefs on page 60 e CB CellPrefsND on page 61 e CB ChartPrefs on page 63 e CB ChartPrefsND on page 64 e CB FormatPrefs on page 135 e CB FormatPrefsND on page 135 e CB GetExcel2007ForegroundMode on page 160 e CB GetRunPrefs on page 172 e CB RunPrefs on page 194 e CB RunPre
30. cbExtPredictorMethodsErrors 24 True or False True includes methods error data in extracted results False does not include methods error data cbExtPredictorMethodsStatistic S 25 True or False True includes methods statistics data in extracted results False does not include methods statistics data cbExtPredictorMethodsParamet ers 26 True or False True includes methods parameters data in extracted results False does not include methods parameters data cbExtPredictorMethodsRanking 126 Crystal Ball Macro Calls 27 True or False True includes methods ranking data in extracted results False Index Parameter Named Constant Value Index Parameter Index Value Value Parameter Values to Use Description does not include methods ranking data The following values are used with Index cbExtDataType to specify the type of Crystal Ball data to extract Table 67 Value Parameter Values that Support Index Constant cbExtDataType Named Constant Value cbDatForeValues Index Value Description Extracts forecast and assumption values Note The constant cbDatForeValues is included for compatibility with Crystal Ball 2000 5 5 5 and is considered deprecated in later versions of Crystal Ball for future compatibility use CBDatValues instead cbDatValues Extracts forecast and assumption values same as cbDatForeValues but name reflects capa
31. 18 o cbDfaMaxExtreme 19 o cbDfaStudentsT 20 o cbDfaYesNo 21 o cbDfaDiscreteUniform 22 o cbDfaBetaPert 23 added in Crystal Ball 7 3 e cbDfaHypergeometric 10 and cbDfaExtremeValue 15 are deprecated in this release Use cbDfaHypergeometricSuccess 17 instead of cbDFAHypergeometric 10 and use cbDfaMinExtreme 18 or cbDfaMaxExtreme 19 instead of cbDfaExtremeValue 15 Table 53 lists the values for Parm1 Parm2 Parm3 and Parm4 for the new DistType constants CB DefineDecVar e Ifasimulation was run earlier it must be reset before CB DefineDecVar is called Changes to Existing Calls 253 CB DefineDecVarND e Ifa simulation was run earlier it must be reset before CB DefineDecVarND is called e Beginning in Crystal Ball 11 1 1 0 00 there are three new decision variable types Binary Category and Custom described in Table 55 e To support these new types a new optional parameter decVarType is added with the following new constants cbDecVarTypeContinuous 0 coDecVarTypeDiscrete 1 cbDecVarTypeBinary 2 cbDecVarTypeCategory 3 and cbDecVarTypeCustom 4 e To support decVarType equal to cbDecVarTypeCustom a new optional parameter customData is added CB DefineForeND e Allparameters are now optional e Allparameter data types are now Variant e The optional WindowSize parameter is obsolete and has been removed e New optional parameters have been added to support the process capability f
32. C 9 alpha greaterthan beta greater than maximum value minimum value 0 3 alpha beta 0 3 alpha beta must be less than must be less than 1000 1000 cbDfaHypergeometr 10 probability trials whole number population whole n a ic D between O and 1 less than number greater than population 0 and less than 1000 cbDfaCustom See 11 cumulative True or sequential sampling n a n a Defining Custom noncumulative True or Distributions on False False is the nonsequential page 107 C D default sampling False see the section on SIPs in the Oracle Crystal Ball User s Guide cbDfaGamma C 12 location scale greater than shape greater than n a 0 0 05 and less than 1000 CB DefineAssumND 105 DistType Parameter Named Constant Value C DistType continuous D Parameter Index Parm4 Description discrete Value Parm1 Description Parm2 Description Parm3 Description Optional cbDfaLogistic C 13 mean value scale greater than n a n a 0 cbDfaPareto C 14 location greater shape greaterthan n a n a than 0 0 05 cbDfaExtremeValue 15 likeliest scale greaterthan max True or min n a C 0 False cbDfaNegBinomial 16 probability shape whole n a n a D between 0 and 1 number greaterthan O and less than 1000 cbDfaHypergeometr 17 success trials whole number population whole n a icSuccess D less than number greater
33. CB PasteData Related Calls Name Description CB CopyData Copies Crystal Ball data in specified range CB Reset This subroutine resets the current simulation prompting you to confirm the reset When you confirm it closes all forecast windows the trend chart the overlay chart and the sensitivity chart then it clears results from the previous simulation This is very useful to use before calls to subroutines and functions that require that a simulation be reset such as CB Freeze although you might prefer CB ResetND because it resets automatically without user response You can also call this subroutine to make sure that simulations start at Trial 1 You do not have to run a simulation before you call this subroutine However it is convenient to run to ensure that no prior simulation results are around Note If you run a simulation using the CB Simulation subroutine without resetting Crystal Ball runs additional trials and adds the results to the existing results This is different from the user interface command which tells you it has reached the maximum number of trials and requires you to reset the simulation CB Reset 191 CB Reset Example This example prompts you to confirm and then clears any simulation data and closes all forecast windows and charts CB Reset CB Reset Related Calls Name Description CB ResetND Resets a simulation without confirmation CB Simulation Runs a simulation for spec
34. Figure 3 CB Com Devkit chm opened to the Decision Class topic E CB Com Devkit e o n 8 Locate Back Stop Refresh Home Contents Index Search Collapse All Language Filter Visual Basic Usage Members See Also CB Com Devkit a Decisioneering CB CBCOMDevKit Optimization Namespace 4 E BooleanOption Enumeration E ConEnumerator Class QJ Constraint Class Decision variable wrapper A Constraint Properties Decision Class Namespace Decisioneering CB CBCOMDevKit Optimization E Constraint Type Property Assembly CBCOMDevKit in CBCOMDevKit dll B Equation Property Version 11 1 1104 0 e DecEnumerator Class e Decision Class Syntax E DecVarValue Type Enumeration IVarEnumerator Interface ce Visual Basic Visual Basic Objective Class E Usage ObjEnumerator Class Dim instance As Decision e ObjReqBase Class E OptCondition Type Enumeration E OptConstraint Type Enumeration OptCounters Class Members E OptDecision Type Enumeration OptEFFBoundType Enumeration All Members Constructors ee y e OptEfficientFrontier Class E OptEFFSelection Type Enumeration 43 XNA Framework El OptEFFTest Type Enumeration d Public Only 3 Q amp OptimizationEvents Interface F a E OptimizationState Enumeration 4 Protected 4 Static S d Inherited ig OptMoreLessCondition Enumeration ig OptObjective Type Enumeration B OptOptimization Type Enumeration e OptOptions Class Decision Default
35. For Index 3 True or False boolean n a Indicates whether the cbBftinputHeader data range has headers If set to True there is header text in the top row or first column depending on the cbBftInputOrientation setting For Index 4 True or False boolean n a Indicates whether the cbBftinputLabel data range has labels If set to True there is label text in the first column or top row depending on the cbBftInputOrientation setting CB BatchFitND 49 Related Value Named Constant Value VBA Data Type Index Value Description For Index 5 cbDfa from Table 76 Integer 0 23 50 53 Indicates a specific cbBftSelectDist distribution or distribution type s to fit to the data For Index 11 Methods listed in Integer 1 5 Specifies a ranking cbBftRankMethod Table 77 method as listed in Table 77 For Index 12 cbBftNewWorkbook Integer 1 Used with Value2 to cbBftOutputLocation indicate whether results should go in a new workbook For Index 12 cbBftNewWorksheet Integer 3 Used with va1ue2 to cbBftOutputLocation indicate whether results should go in a new worksheet For Index 13 True or False boolean n a Indicates whether results cbBftOutputFormat should be formatted if True formatting is applied For Index 14 True or False boolean n a Indicates whether to cbBftOutputCorrelationM create a correlation atrix matrix if True the matrix is produced For Index 15 True or
36. For zndex 9 Integer cbScatterPointSymbolMarble 5 Draws spherical scatter points default For zndex 9 Integer cbScatterPointSymbolHorizonta 6 ILine Uses a horizontal line for scatter points For zndex 9 Integer cbScatterPointSymbolVerticalli 7 ne Uses a vertical line for scatter points CB ScatterPrefSND 205 Used With Specified Values of Index Named Constant Value Index Value Description For Index 9 Integer cbScatterPointSymbolCross 8 Uses a crossed line for scatter points For Index 9 Integer cbScatterPointSymbollnvertedTr 9 Uses an inverted triangle for iangle scatter points For Index 14 Integer cbScatterOrderedFit 1 Specifies an ordered fit line For Index 14 Integer cbScatterRegression 2 Specifies a linear regression line For Index 16 Integer cbScatterLimitAuto 1 Automatically limits the number of trials based on plot size For Index 16 Integer cbScatterLimitTrialNumber 2 Shows only a fixed number of trials defined through Index 17 cbScatterCriteriaLimitNumber For Index 16 Integer cbScatterLimitTrialPercentage 3 Shows only the specified percentage of trials defined through Index 18 cbScatterCriteriaLimitPercentag e CB ScatterPrefsND Example The following example runs a simulation with 10 000 trials and then performs the described operations to define and open a scatter chart CB Simulation 10000 The next command removes all
37. In addition to this book the OptQuest Developer Kit includes the following files available in the specified folders under the Crystal Ball installation folder by default C Program Files Oracle Crystal Ball e CBCOMDevkKit tlb in the Bin folder accessible directly and through CBDevKit xla in the Crystal Ball installation folder e OptDevKitRuntimeSample xls in the Examples folder a sample spreadsheet with commented code so you can follow how the OptQuest Developer Kit was used to create several sample optimizations see OptDevKitRuntimeSample xls on page 276 for details e CB Com Devkit chm in the Docs folder an online help file that describes the methods and properties within each class of the OptQuest Developer Kit see CB Com Devkit chm on page 274 for more information What You Will Need Crystal Ball Decision Optimizer runs on several versions of Microsoft Windows and Microsoft Excel For a complete list of required hardware and software see the current Crystal Ball Installation Guide OptQuest Developer Kit Use and Structure This section gives specific requirements for installing and using the OptQuest Developer Kit It also summarizes the structure of the Developer Kit and introduces CB Com Devkit chm a help file that serves as an online reference to the classes methods properties and other elements of the OptQuest Developer Kit Specific Requirements for Use If you have a license to run OptQuest
38. Returned Value Returned Data Type The current Crystal Ball load status boolean CB Shutdown Example This code unloads Crystal Ball and returns TRUE in cell B2 when unloading is complete Range B2 Value CB Shutdown CB Shutdown Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is currently loaded within Excel CB Shutdown 225 Name Description CB GetCBAutoLoad Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Excel opens CB SetCBAutoLoad Sets or cancels autoloading with Excel determines whether Crystal Ball is set to open whenever Excel opens CB Startup Loads Crystal Ball into Excel if possible and indicates when Crystal Ball has been successfully opened CB SimResult This function returns the criterion that finally stopped the most recent simulation Note Before calling this function run a simulation or the function returns cbErrNotReady Table 177 CB SimResult Returned Data Type Returned Value The stopping criterion used O for a calculation error 1 for maximum number of trials 2 for Crystal Ball precision control or 3 for OptQuest confidence testing Returned Data Type Variant CB SimResult Example This example runs a simulation If Crystal Ball stops the simulation after the maximum number of trials 1000 in this example CB SimResult puts a 1 in cell B3
39. Selects all decision variables in the current spreadsheet CB SelectFore on page 209 Selects all forecasts in the current spreadsheet CB SensPrefs on page 210 Opens the Sensitivity Preferences dialog for the selected sensitivity chart CB SensPrefsND on page 210 Sets preferences for the specified sensitivity chart CB SetAssum on page 213 Changes certain attributes for the assumption in a cell CB SetCBAutoLoad on page 214 Sets or cancels autoloading with Excel determines whether Crystal Ball is setto open whenever Excel opens CB SetCBWorkbookPriority on page 215 Sets the running order for macro applications when multiple workbooks are open CB SetDecVar on page 216 Changes certain attributes for a decision variable CB SetExcel2007ForegroundMode on page 218 Sets the Run Preferences foreground mode setting for Excel 2007 in Normal speed CB SetFitRange on page 219 Specifies the data range to be used as input for CB Fit CB SetFore on page 219 Changes the settings for a forecast CB SetRange on page 223 Sets the certainty range for one or all forecasts CB Shutdown on page 225 Closes Crystal Ball while leaving Excel open CB SimResult on page 226 Returns criteria that stopped the last simulation CB Simulation on page 226 Runs a simulation for the specified number of iterations
40. are setting See Table 31 Crystal Ball Macro Calls Parameter VBA Data Type Description Value1 Optional Variant Specifies settings for the preference indicated by Index See Table 31 Value2 Optional Variant Specifies settings for the preference indicated by Index See Table 31 Table 31 shows each Index value and the corresponding Valuei and Value2 parameter values Table 31 Index and corresponding Value1 and Value2 Parameters Named Constant Value Index Value Description Value1 Optional Value2 Optional cbRptOK 1 Generates the report n a n a Use this parameter after setting other report options cbRptTrendChart 2 Includes all open trend boolean True includes Integer 1 to 200 charts in the reportata the chart False does not defines the percent scale specified scale of the chart cbRptSensitivChart 3 Includes all open boolean True includes Integer 1 to 200 sensitivity charts in the the chart False does not defines the percent scale report at a specified of the chart scale cbRptForeSummaries 4 Includes summary boolean True includes n a information about the the summaries False included forecasts does not cbRptForeStatistics 5 Includes the statistics boolean True includes n a table for each included the statistics False does forecast not cbRptForeCharts 6 Includes the frequency boolean True includes Integer 1 to 200 chart for
41. e Functions For Use in Excel Models on page 32 e Opening and Closing Crystal Ball on page 32 e Setting Up and Running Simulations on page 33 e Controlling Crystal Ball Chart Windows on page 34 e Handling Crystal Ball Results on page 35 e Setting and Getting Preferences on page 36 e Special Calls on page 37 Introduction 23 How to Use the Crystal Ball Developer Kit 24 This section discusses e Calling Crystal Ball From Visual Basic For Applications VBA Programs e Calling Crystal Ball From an External Visual Basic VB Program Note that macros created with the Crystal Ball Developer Kit cannot be placed in spreadsheet cells although some calls have equivalents with names ending in FN that can be used directly in models For a list of these see Functions For Use in Excel Models on page 32 Calling Crystal Ball From Visual Basic For Applications VBA Programs To call Crystal Ball subroutines and functions from VBA programs ensure that the following conditions are true e Crystal Ball must be running e The VBA program must have a reference to Crystal Ball To create a reference to Crystal Ball from your programs Open your VBA program In Excel for example select Tools then Macro and then Visual Basic Editor In the menu select Tools then References Look in the Available References list for CBDevKit e Ifthe reference appears in the list check it and click OK e Ifth
42. simulations using CB Simulation It calls CheckData on the first simulation and then increments the iterations counter at the start of each simulation If you call CB StartMultiSimul before multiple simulations then call CB StopMultiSimul after the simulations are run Table 179 CB StartMultiSimul Parameters Parameter Rescan Optional VBA Data Type boolean Value True or False Description Indicates whether to rescan the workbook for each simulation call within a multiple simulation The default is False which eliminates rescans for faster processing This optional parameter only works in Extreme Speed SaveAssumValues Optional boolean True or False If set to True saves assumption values from multiple simulations for use in sensitivity analysis and other analyses The default is False MultiAutoDownshift Optional boolean True or False With CB AutoDownshift set to True if CB SingleStep 229 Parameter VBA Data Type Value Description MultiAutoDownshi ft is set to True Crystal Ball automatically downshifts to Normal speed when Extreme speed incompatibilities occur No dialog appears The default is False This optional parameter only works in Extreme Speed Note Ifa non decision variable cell referenced in a forecast formula a forecast precedent is changed between simulations there might be slight differences in results depending on whether
43. 1000 trials opens a trend chart and selects a forecast cell Then it clears the list of forecasts included in the trend chart adds the selected forecast to the trend chart sets the value axis to have a minimum of 0 and a maximum of 1000 and includes certainty bands of 0 25 50 95 and 100 CB Simulation 1000 CB OpenTrend Range B7 Select CB TrendPrefsND cbTrdChooseFore cbChfClearList CB TrendPrefsND cbTrdChooseFore cbChfAdd CB TrendPrefsND cbTrdValueAxis cbValMinMaxDiv 0 1000 CB TrendPrefsND cbTrdCertaintyBands 0 25 50 95 100 CB TrendPrefsND Related Call Name Description CB TrendPrefs Opens the Trend Preferences dialog for the selected trend chart CB TrendPrefSND 235 CB TwoDSimulation This call lauches the 2D Simulation tool wizard This tool estimates risk by running an outer loop to simulate uncertainty values and then freezes the uncertainty values while it runs an inner loop of the whole model to simulate variability This process repeats for some small number of outer simulations providing a portrait of how a given forecast distribution varies due to the uncertainty Note Before calling CB TwoDSimulation reset the simulation CB TwoDSimulation Example This example resets the Crystal Ball simulation and opens the 2D Simulation wizard CB ResetND CB TwoDSimulation CB TwoDSimulation Related Calls Name Description CB TwoDSimulationND Runs the 2D Simulati
44. 111 The following table shows named constant and index values for the Index parameter Table 111 CB GetDecVar Index Parameter Values Required Integer Named Constant Value Index Value Description cbDecName 1 Returns the decision variable name cbDecMin 2 Returns the decision variable minimum lower bound cbDecMax 3 Returns the decision variable maximum upper bound cbDecType 4 Returns the type of decision variable 0 Continuous 1 Discrete 2 Binary 3 Category 4 Custom cbDecStep 5 For discrete variables this returns the step size cbDecFrozen 6 Returns whetherthe decision variable in the selected cell is frozen cbDecCustomData 7 Returns the custom value list or range if coDecType 4 Custom CB GetDecVar Example This example puts all the decision variable information for the decision variable in cell B3 into cells F2 through F8 In a macro you can enter For i 1 To 7 CB CheckData Worksheets sheet3 Range F1 Offset i Value CB GetDecVar Worksheets sheet1 Range B3 i Next i CB GetDecVar 159 CB GetDecVar Related Calls Name Description CB DefineDecVar Defines or changes a decision variable in a selected cell using a dialog CB DefineDecVarND Defines or changes a decision variable in a selected cell without a dialog CB EnumDecVar Enumerates decision variable cells for all open workbooks CB SetDecVar Changes certain attr
45. 53 can be used as Value1 e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use Value2 to specify the number of the target parameter cbBftOutputLocationCell 25 If coBftOutputLocation 12 returns cbBftCurrentWorksheet 4 can be used to return the cell in the upper left corner of the output range 146 Crystal Ball Macro Calls Named Constant Value cbBftOutputCorrelationThreshold Index Value 26 Description If cbBftOutputCorrelation 15 returns True can be used to return the correlation threshold absolute value default 0 0 cbBftOutputGoodnessOfFitSheet 27 If coBftOutputGoodnessOfFitReport 17 returns True can be used to return the sheet name string of the report cbBftOutputAssumSheet 28 If cbBftOutputAssumReport 18 returns True can be used to return the sheet name string of the report cbBftOutputWorksheet 29 Returns the name of the sheet with the main Batch Fit output report Table 91 CB GetBatchFitOption Value1 Parameter Optional Variant Used With Specified Named Constant or Values of Index boolean Value Index Value For Index 23 One of the n a cbBftFitDistLockPa
46. BatchFit on page 46 Launches the Batch Fit tool CB BatchFitND on page 46 Runs the Batch Fit tool without displaying dialogs CB Bootstrap on page 55 Launches the Bootstrap tool CB BootstrapND on page 56 Runs the Bootstrap tool without displaying dialogs CB CBLoaded on page 59 Indicates whether Crystal Ball is currently loaded within Excel CB CellPrefs on page 60 Sets attributes of Crystal Ball cells using a dialog CB CellPrefsND on page 61 Sets attributes of Crystal Ball cells without using a dialog CB ChartPrefs on page 63 Sets chart preferences for the selected forecast using a dialog CB ChartPrefsND on page 64 Sets chart preferences for selected forecast without a dialog CB CheckData on page 67 Checks Crystal Ball data cells for validity initializes variables with dialogs in case of error CB CheckDataND on page 68 Checks Crystal Ball data cells for validity initializes variables without error prompting CB ClearData on page 69 Erases assumptions decision variables and forecasts from selected cells after prompting Alphabetic List of Crystal Ball Macro Calls 27 Name CB ClearDataND on page 70 Description Erases assumptions decision variables and forecasts from selected cells without prompting CB CloseAllCharts on page 70 Closes all open chart windows equivalent to Analyze then Close All
47. Because the normal distribution requires only these two parameters use cbParmNone to stand in as the third unused parameter in the argument list CB DefineAssumND receives this information about the distribution and parameter set and defines the assumption s distribution with a mean of 10 and a standard deviation of 0 2 Range B5 Select Value CB DefineAltParms cbDfaNormal cbParmMean cbParmStDev cbParmNone CB DefineAssumND Value 10 0 2 CB DefineAltParms 101 CB DefineAltParms Example 2 This example defines the assumption in cell B6 as a normal distribution using the 10th and 90th percentiles The 10th percentile is 10 the 90th percentile is 12 and cbParmNone is a placeholder in the argument list Range B6 Select Valuel CB DefineAltParms cbDfaNormal cbParmPercentile 10 _ cbParmPercentile 90 cbParmNone CB DefineAssumND Valuel 10 12 Note If you use the numeric value of the index instead of the constant name for cbParmPercentile as in Example 3 you must use the sample syntax 0 lt percentile gt so that the function can identify the parameter by the numeric value CB DefineAltParms Example 3 This example selects the assumption in cell B7 and defines a triangular distribution using the 25th percentile the likeliest value and the 75th percentile CB DefineAssumND receives this information about the distribution and parameter set and defines the assumption s distribution with
48. C300 LSLs lower specification limit for process capability analysis For Index 7 A cell reference with Variant n a Sets the selected range cbDataAnalysisSelectUS format Range A1 C300 of values as forecast L or A1 C300 USLs upper specification limit for process capability analysis For Index 8 A cell reference with Variant n a Sets the selected range cbDataAnalysisSelect format Range A1 C300 of values as forecast Target or A1 C300 Targets target values for process capability analysis For Index 9 True or False boolean n a Indicates whether to cbDataAnalysisAutoOpe open forecast charts nCharts automatically when the data analysis runs True automatically open charts For Index 10 Constants Table 24 Integer See Table 24 Uses cbChtChartType cbDataAnalysisSetViewT ype 94 Crystal Ball Macro Calls constants from CB ChartPrefsND to determine which chart view appears See Table 24 for constants The following views are allowed frequency cumulative frequency reverse cumulative frequency capability Related Value Named Constant Value VBA Data Type Index Value Description metrics statistics percentiles and goodness of fit For Index 11 True or False boolean n a Indicates whether cbDataAnalysisFitTo forecast charts should be Distribution fitted to a distribution True fit to distributions For Index 12 Constants Table 77 Integer See Table 77 Specifies a
49. CB CloseChart on page 71 Closes the selected chart of the given type CB CloseFore on page 72 Closes the forecast chart CB CloseSensitiv on page 72 Closes the selected sensitivity chart CB CloseTrend on page 73 Closes the selected trend chart CB CopyData on page 74 Copies Crystal Ball data in the specified range CB CopyDataND on page 74 Copies selected assumptions decision variables or forecasts CB CopyScatter on page 75 Copies the selected scatter chart to the clipboard CB CopySensitiv on page 76 Copies the selected sensitivity chart to the clipboard CB CopyTrend on page 76 Copies the selected trend chart to the clipboard CB CorrelateND on page 77 Defines a correlation coefficient between two selected assumptions CB CreateChart on page 79 Creates a new chart of the specified type with the optional name if specified CB CreateRpt on page 80 Creates a report from the current simulation and restored results optimization with an appropriate license or time series forecast using a dialog CB CreateRptND on page 80 Sets report preferences and creates a report from the current simulation and restored results optimization with an appropriate license or time series forecast without a dialog CB DataAnalysis on page 91 Launches the Data Analysis tool CB DataAnalysisND
50. CB GetForeStat on page 167 Returns statistics for a specific forecast cell CB GetLockFitParm on page 170 Returns whether a distribution and optionally specific parameters have locked values for fitting purposes CB GetRunPrefs on page 172 Returns a Run Preferences setting CB GetTwoDSimulationOption on page 173 Returns current settings for the 2D Simulation tool CB GetVersion on page 176 Returns the current Crystal Ball version as a full build number or version ID number CB GetWorksheetVersion on page 178 Returns the Crystal Ball data version of the active or specified worksheet CB IsCBObject on page 179 Tests if a worksheet or workbook contains Crystal Ball data CB Iterations on page 180 Returns the number of trials run in a simulation CB LockFitParm on page 181 Sets parameter locking for distributions and optionally specific parameters CB MacroResult on page 182 Tells you if a Crystal Ball macro call worked correctly CB MacroResultDetail on page 184 Similar to CB MacroResult with additional error information CB OpenChart on page 186 Opens the selected chart of the specified type CB OpenFore on page 187 Opens a forecast window for the selected cell CB OpenSelection on page 188 Opens all charts defined for cells in the selected range CB OpenSensitiv on page 189 Opens
51. CB Simulation 1000 Range B3 CB SimResult CB SimResult Related Calls Name Description CB RunPrefsND Sets what stopping criterion to use without a dialog CB Simulation Runs a Crystal Ball simulation CB Simulation This subroutine runs a Crystal Ball simulation on any open workbooks with Crystal Ball data for a specified number of trials 226 Crystal Ball Macro Calls Note The hide and minimize options are useful for increasing the speed of simulations Caution Note that Crystal Ball cannot run a simulation ifa cell with Crystal Ball data is located in a write protected worksheet Ifyou run a simulation using CB Simulation without resetting Crystal Ball runs additional trials and adds the results to the existing results This means you can run more trials than the maximum set with the Run Preferences dialog or a Developer Kit macro call Table 178 CB Simulation Parameters Parameter Iterations VBA Data Type Long Value Any positive integer Description Specifies the number of trials to run If you already ran a simulation and did not reset it Crystal Ball runs this many more trials Obsolete Asynchronous Optional Variant null Used as a placeholder for the Asynchronous parameter removed starting with Crystal Ball 11 1 1 0 00 HideForecasts Optional Variant True or False Sets whether to suppress forecast windows from opening normally during simul
52. CB StartMultiSimul on page 229 e CB StopMultiSimul on page 231 e CB WorksheetProtection on page 241 Controlling Crystal Ball Chart Windows The macro calls in this group can be used to e Select which chart windows to open or close e Open charts for selected cells The following sections describe calls that are used to control Crystal Ball windows e CB CloseAllCharts on page 70 e CB CloseChart on page 71 e CB CloseFore on page 72 e CB CloseSensitiv on page 72 e CB CloseTrend on page 73 e CB OpenChart on page 186 e CB OpenFore on page 187 e CB OpensSelection on page 188 e CB OpenSensitiv on page 189 e CB OpenTrend on page 189 34 Crystal Ball Developer Kit Overview Managing Charts The macro calls described in the following sections can be used to perform chart management tasks such as creating charts copying charts enumerating or listing charts and deleting charts CB CopyScatter on page 75 CB CopySensitiv on page 76 CB CopyTrend on page 76 CB CreateChart on page 79 CB DeleteChart on page 115 CB EnumChart on page 117 CB SelectChart on page 208 Handling Crystal Ball Results The macro calls in this group can be used to Set the certainty range for forecasts Get assumption decision variable and forecast values statistics and percentiles Extract data Create reports Save and restore results
53. Coding an Optimization An optimization has three phases building the model setting up the optimization and then running it The sample code in OptDevKitRuntimeSample xls illustrates these steps with two sample optimizations The first is based on Portfolio Analysis xls in the Crystal Ball Examples folder The second adds Efficient Frontier analysis If you haven t already you might find it helpful to complete Tutorial 2 in the Oracle Crystal Ball Decision Optimizer OptQuest User s Guide This tutorial explains how to complete the Portfolio Analysis xls model set up an optimization manually and then run it You will then understand the manual process and can better follow what the code is doing The following sections discuss optimization coding strategies e Starting Out on page 277 e Continuing on page 278 e Error Handling on page 278 e Accessing OptQuest with the Crystal Ball Developer Kit on page 278 Note Before you begin coding you should learn to perform optimizations with OptQuest Many of the items used in OptQuest such as constraints and objectives match the corresponding objects in the OptQuest Developer Kit See the Oracle Crystal Ball Decision Optimizer OptQuest User s Guide for complete descriptions of the optimization process and items Starting Out The sample code in OptDevKitRuntimeSample xls begins by explicitly declaring variable types for several variables Option Explicit Private Wit
54. Crystal Ball data Freeze data cells and run simulations The following sections describe macro calls that are used to set up and run simulations CB AlertOnArgumentError on page 42 CB AlertOnMacroResultError on page 43 CB AlertOnObsolete on page 43 CB AutoDownshift on page 45 CB ClearData on page 69 CB ClearDataND on page 70 CB CopyData on page 74 CB CopyDataND on page 74 CB CorrelateND on page 77 CB DefineAltParms on page 99 CB DefineAssum on page 102 CB DefineAssumND on page 103 CB DefineDecVar on page 108 CB DefineDecVarND on page 109 CB DefineFore on page 112 CB DefineForeND on page 113 CB Fit on page 131 CB Freeze on page 138 CB FreezeND on page 138 CB GetFitParm on page 160 CB GetLockFitParm on page 170 CB LockFitParm on page 181 Setting Up and Running Simulations 33 e CB MacroResult on page 182 e CB MacroResultDetail on page 184 e CB PasteData on page 190 e CB Reset on page 191 e CB ResetND on page 192 e CB SelectAssum on page 207 e CB SelectDecVar on page 209 e CB SelectFore on page 209 e CB SetAssum on page 213 e CB SetCBWorkbookPriority on page 215 e CB SetDecVar on page 216 e CCB SetFitRange on page 219 e CB SetFore on page 219 e CB Simulation on page 226 e CB SingleStep on page 229 e
55. Decision variable constructor Instance 4 Declared NET Compact Framework Only Member Description B OptRunForType Enumeration Decision String String Decision variable constructor using cell address E OptRuntime Class BaseCase Decision variable step E Opt Runtime AfterSmulstionEventHandler Delegate CustomValues A set of possible values for this Decision Variable ig OptRuntime EfficientFrontierEventHandler Delegate 1 E OptRuntime OptEventHandler Deleaate M If you click the Visual Basic tab Visual Basic appears in the Language Filter menu and the Visual Basic tab is selected in the Syntax tab group OptDevKitRuntimeSample xls This sample file contains code for two different optimization sequences both based on the Portfolio Allocation example models This file is located in the Examples folder beneath the main Crystal Ball installation folder To use it open OptDevKitRuntimeSample xls in Crystal Balll Choose to enable the macros Then open your development environment for example the Excel Visual Basic Editor In the project tree select the class module PortfolioOptimizeClass Commented sample code appears in the code window You can run the code by clicking buttons on the Model worksheet Then you can examine the code and the comments to see how the samples were constructed For more information about this sample see Coding an Optimization on page 277 following 276 Using the OptQuest Developer Kit
56. Hotencop dT 13 CLOUD sus nna guide ait 74 RAO RUC AN tesi Sere aed Peru t Dead T bd Osa Weed peed mie Ay sux perta cn REM A ae 74 PAGO VOC TIT is DO DO T 15 eng nec A MM E MINER MM dM CU UE 76 CECOM ION edad li bb dde 16 CB Cone ae DF PME TT CBE NEENA ian O T9 A ev 80 39 40 A 0 COD m angie eed CQ EB DatalualyeteN D tc T al A A A E E E E A 96 CRIS AENA T A AAA AA A A he 96 CB Dee P m 99 NRI y tija di bd ea e i Ea 102 EBDStneASSONI MD anesan O 103 CB DECIS HERD EB TIN IY aD AOS EAP A nucle E haat M IMPER endanger XE KE Mapa ERA 112 EME A n 113 CE Dacia NETT A BH A a ets 115 UB EBUASSUTT cat ecl en eO GG E Cr eor etd AA A ved FUE UU T ur E 115 CREMA coa TT esl d COIN AAA A msc 118 CE EIEN eee eb T EA IT P P ee lisi lr fece 121 AECA UPPER 122 CE EstactDataN Dy ee m 123 A ies ionshenebinienibane teadaces send aankeaglby a letras 131 CS IP TOTS T PTE TE T epa Ede UMP SNO E I DM nda ama DeRip Mud Blab DAR ET 139 CB Foimat te SPD nora a LOO UB PIEBZE essem ak O LO CASO MR I RT EN 138 RIAL DUI mec MM T err rer 140 post nt Miley A ee
57. OptQuest results section following an OptQuest optimization run cbRptSectPredictorSeries 10 Includes the Predictor results section following a Predictor forecasting run With Index set to cbRptPredictorMethods you can use the following constants as the Valuel parameter to specify which forecasting methods to include in Predictor report data see Table 41 Table 41 For Index cbRptPredictorMethods Value1 Values Optional Integer Named Constant Value Index Value Description cbPredictorMethodsNone 1 Includes no methods cbPredictorMethodsAll 2 Includes all methods cbPredictorMethods1Best 3 Includes the method with the best accuracy cbPredictorMethods2Best 4 Includes the method with the second best accuracy cbPredictorMethods3Best 5 Includes the method with the third best accuracy Use cbRptOK to generate the report after you use the other index values to set report preferences A simulation must not be in progress If a simulation has not yet run the report only includes assumption information Note To add individual charts use constants cbRptChooseOverlay cbRptChooseTrend and cbRptChooseSensitivity from Table 30 Use these constants with CB SelectChart and the constants in Table 38 If you create a chart through the Developer Kit open it before including it in a report Otherwise the chart will show up in the report with a no data available message See the Oracle Crystal Ball
58. Optional Variant See Table 157 Works with the Index parameter to set sensitivity chart preferences Value2 Optional Variant See Table 158 Works with Index 5 or 6 to set the maximum or minimum number of sensitivity values Table 156 following lists named constant and index values for the Index parameter Table 156 CB SensPrefsND Index Parameter Values Required Integer Named Constant Value cbSenTargetFore Index Value Description Defines the selected forecast cell as the target forecast cbSenMeasure Sets whether to measure sensitivity by rank correlation or by contribution to variance according to Valuel cbSenDisplayOnlyHighest Sets to display only the highest sensitivities according to Value1 and Value2 cbSenDisplayGreaterThan Sets to display only sensitivities greater than Value2 according to Valuel cbSenlitle Gives the sensitivity chart a title according to Valuel cbSenChooseAssum Clears and selects the assumptions for the sensitivity chart according to Valuel Note Index values cbSenIncludeAssum 3 and cbSenIncludeOtherFore 4 are obsolete Table 157 following lists values for the optional Value1 parameter Table 157 CB SensPrefsND Value1 Parameter Values Optional Variant Used With Specified Named Constant or Values of Index boolean Value Index Value Description For Index 2 Boolean True or False OR n a True measur
59. RUNING anini A Gad ee A 266 Crystal Ball R ntime Licensing REQUITGMONS wiasccas vistors surcar senecta pindahna Sestius ved dd daa Padika munina 267 Introduction Application developers can use the current version of the Crystal Ball Developer Kit to create custom applications for others who are not skilled users of Crystal Ball This feature is called Crystal Ball Runtime This appendix describes Crystal Ball Runtime and explains how to install and use it About Crystal Ball Runtime When your custom application calls CB RuntimeMode CB RuntimeMode on page 200 the Crystal Ball menus and toolbar or ribbon in Excel 2007 are hidden You can give users the ability to run reset and single step through simulations by creating your own user interface controls with Visual Basic or VBA that call appropriate Crystal Ball Developer Kit subroutines and functions You can also use the Crystal Ball Developer Kit macros to create controls that extract data create charts and reports and more When simulations run in Runtime mode the Crystal Ball Control Panel is switched off by default However you can use Visual Basic or VBA to switch it on again using appropriate calls to CB Simulation or CB RunPrefsND Even if the Control Panel dialog is displayed though the Run Analyze and Help menus are hidden Users can access Predictor if you use calls from the Predictor Developer Kit to access Predictor features See Appendix B Using the Predic
60. Rescan is set to True or False If custom code is created where precedent values are changed manually between simulations these models need to call StartMultiSimul with Rescan set to True This change might also be true for some models running in Extreme Speed CB StartMultiSimul Example This example runs 100 simulations with rescanning The array Median is filled with the values of the medians for each simulation in the multiple simulation Dim Median 50 As Double CB StartMultiSimul True For i 1 To 100 CB ResetND CB Simulation 1000 Median i CB GetForePercent Workbooks Futura with OptQuest xls Worksheets Model Range C7 50 Next i CB StopMultiSimul CB StartMultiSimul Related Calls Name Description CB Simulation Runs a simulation CB StopMultiSimul Marks the end of multiple simulations CB Startup If Crystal Ball is not loaded into Excel this function loads Crystal Ball It returns True when Crystal Ball is loaded 230 Crystal Ball Macro Calls Table 180 CB Startup Returned Data Type Returned Value Returned Data Type The current Crystal Ball load status boolean CB Startup Example This example loads Crystal Ball and returns TRUE in cell B2 when loading is complete Range B2 Value CB Startup CB Startup Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is loaded in Excel CB GetCBAutoLoad Returns the Crystal Ball a
61. Table 15 CB BootstrapND Index Parameter Required Integer Named Constant Value Index Value Description cbBtsChooseTarget 1 Sets the target forecast for the bootstrap operation operates on the forecast in the currently selected cell cbBtsChooseDataRange 2 Selects the data values for the bootstrap operation operates on the currently selected cell range cbBtsMethod 3 Used with Index2 to specify a bootstrap method cbBtsAnalyze 4 Used with rndex2 to set bootstrap analysis options 56 Crystal Ball Macro Calls Named Constant Value Index Value Description cbBtsPercent 5 Used with Index2 to specify percentile settings cbBtsSample 6 Used with Index2 to set sample options cbBtsForeOption 7 Used with Index to set forecast chart window display options cbBtsRun 8 Runs the Bootstrap tool Table 16 CB BootstrapND Index2 Parameter Optional Integer Related Value Named Constant Value Index Value Description For Index 3 cbBtsMethod cbBtsMethodResample 1 Runs one simulation and Integer resamples the data faster but less accurate For Index 3 cbBtsMethod cbBtsMethodMultiSim 2 Runs multiple simulations and Integer creates diverse data slower but more accurate For Index 4 cbBtsAnalyze cbBtsAnalyzeStat 1 Analyzes distributions of Integer statistics For Index 4 cbBtsAnalyze cbBtsAnalyzePercent 2 Analyzes distributions of Integer percentiles
62. The named constant will not work If no mode is calculated Index cbFstMode returns VALUE CB GetForeStat Example 1 This example runs a simulation of 1000 trials and then pastes the standard deviation of the forecast in B7 into cell M6 In a macro you can enter CB Simulation 1000 Range M6 Value CB GetForeStat Range B7 cbFstStdDev CB GetForeStat Example 2 This example before a simulation displays 0 in the cell After a simulation it displays the standard deviation of the forecast in B7 In a worksheet cell you can enter CB GetForeStatFN B7 5 Note You must use the numeric value of the Index parameter in a worksheet cell The named constant will not work CB GetForeStat Related Calls Name Description CB EnumFore Enumerates forecast cells for open worksheets CB GetCertainty Returns the certainty level of achieving a forecast value at or below a specific threshold CB GetForeStat 169 Name Description CB GetFore Retrieves information for a specific forecast cell CB GetForePercent Returns percentiles for forecast cells CB Simulation Runs a Crystal Ball simulation CB GetLockFitParm This function returns a different value depending on the parameter s passed to the call e IfCB GetLockFitParm is called with only the distribution index it returns a boolean indicating whether locking is On or Off for that distribution e IfCB GetLockFitParm is called with a
63. True or not False cbForFrozen 19 Returns whether the forecast cell is frozen cbForLSL 20 Returns a lower specification limit LSL for the forecast cbForUSL 21 Returns an upper specification limit USL for the forecast cbForTarget 22 Returns a target value forthe forecast Note The third constant for Index cbForWindowSize is obsolete and has been removed from Crystal Ball 7 x and 11 x CB GetFore Example This example puts information for Index constants 1 through 5 for the forecast in cell B3 into cells F1 through F5 In a macro you can enter For i l To 5 CB CheckData Worksheets sheet3 Range F1 Offset 1 Value CB GetFore Worksheets sheet1 Range B3 i Next i Notice that a message appears to indicate the third constant is obsolete and cell F3 is left blank 164 Crystal Ball Macro Calls CB GetFore Related Calls Name Description CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssum Gets assumption cell information CB GetDecVar Retrieves information for a specific decision variable cell CB GetForePercent Gets a forecast cell percentile CB GetForeStat Gets a forecast cell statistic CB SetFore Changes forecast attributes without redefining the forecast CB GetForeData This function returns the value for the given trial for a specific forecast cell Note To call this function from a worksheet use the name CB GetF
64. User s Guide for more information on creating reports CB CreateRptND Example 1 This example runs a simulation so that the report can have forecast and charts in it Then it defines the report type as Custom sets preferences not to include a trend chart an overlay chart or any assumption information It does include forecast charts for all the forecasts but no other forecast statistics or information The charts are in Excel format When you use a ClearList constant it clears all individually selected items of that type However if you have used an All constant such as cbChfAll using cbChfClearList is overridden by the All CB CreateRptND 89 constant and in this case information is still included for all forecasts For this reason itis good practice to use a Chosen constant after a ClearList constant CB Simulation 1000 CB CheckData CB CreateRptND cbRptSection True cbRptSectForecasts CB CreateRptND cbRptDefinedType cbRptCustom CB CreateRptND cbRptTrendCharts False CB CreateRptND cbRptSensitivityCharts True 150 CB CreateRptND cbRptOverlayCharts False CB CreateRptND cbRptChooseFore cbChfAll CB CreateRptND cbRptForeSummaries False CB CreateRptND cbRptForeStatistics False CB CreateRptND cbRptForeCharts True 50 CB CreateRptND cbRptForePercentiles True cbPctDeciles CB CreateRptND cbRptChooseAssum cbChaClearList CB CreateRptND cbRptChooseAssum cbChaChosen CB CreateRptND cbRptChartType cbChtExcel CB C
65. Value cbForUSL 21 Enters an upper specification limit for the forecast according to Value cbForTarget 22 Enters a target value for the forecast according to Value Note Index cbForWindowSize 3 is obsolete and is not included here Table 174 following describes the Value parameter Table 174 CB SetFore Value Parameter Values Required Variant Used With Specified Values of Index Value Description For Index 1 cbForName String Forecast name in quotes Specifies the new forecast name For Index 2 cbForUnits String Units name in quotes Specifies the new units CB SetFore 221 Used With Specified Values of Index For Index 4 cbForAutoOpen Boolean Value True or False Description True displays the window automatically False does not For Index 5 cbForOpenWhen Integer 0 or 1 coOpnWhenRunning 0 cbOpnWhenStopped 1 Sets when to display the forecast chart O during the simulation 1 after the simulation stops For Index 6 cbForPrecision Boolean True or False True turns on precision control False turns it off For Index 7 cbForPrecisionAbsolute Boolean True or False True sets the confidence interval to be in absolute units False sets it in relative terms For Index 8 Units Sets the size of the confidence interval in cbForPrecisionAbsoluteValue Double terms of forecast units For Index 9 0 01 to 99 99 S
66. apply formatting cbExtSheetName 11 A string value representing a sheet name The name of the sheet where extracted data is placed The sheet name must follow appropriate sheet naming restrictions cbExtStartCell 12 A string value representing a starting cell location Specifies the upper left cell of the extracted data cbExtStartSheet 13 See Table 71 Indicates where to extract the data described in Table 71 1 cbExtNewWorkbook 2 cbExtCurrentWorkbook_ NewSheet 3 cbExtCurrentWorkbook_ CurrentSheet Note Calling ExtractDataND with this value will overwrite any settings through cbExtExistingSheet cbExtDataOptimizerType 14 See Table 72 Indicates which OptQuest data to extract following an optimization run If not explicitly set the current settings from the Extract Data dialog are used cbExtChooseDecVar 15 See Table 73 Indicates which decision variable data to extract following an optimization run If not explicitly set the current settings from the Extract Data dialog are used cbExtDataPredictorType 16 Constant name or number as described in the next table cell Specifies which type of Predictor data to extract e 1 cbDatPredictorResults extracts results data e 2 cbDatPredictorMethods extracts methods data Note The constant is followed by a boolean True or False to CB ExtractDataND 125 Index Parameter Named Co
67. cells in one row or one column Supplies a list of values for use with the Custom decision variable type cbDecVarlypeCustom Note The decVarType and customData parameters are added for Crystal Ball 11 x Table 55 Named Constant and Index Values for the decVarType Parameter Optional Integer Named Constant Value Index Value cbDecVarTypeContinuous 0 Description Sets the decision variable type to Continuous it can assume any value between the lower and upper bounds Continuous is the default type if decVarType is not used and StepSize is blank or 0 cbDecVarTypeDiscrete 1 Sets the decision variable type to Discrete it can assume values at specific intervals based on step size between the lower and upper bounds If decVarType is not used and Stepsize is neither blank nor O the decision variable type is set to Discrete cbDecVarTypeBinary 2 Sets the decision variable type to Binary it can assume the value O represents No or 1 represents Yes Also known as the Yes No type cbDecVarTypeCategory 3 Sets the decision variable type to Category itcan assume any integer between the upper and lower bounds inclusive without regard to order The bounds are also integers The decision variable values are nominal and represent choices or categories instead of arithmetic values For more information see CB DefineDecVarND Example 4 cbDecVarTypeCustom 4 110 Crystal Ball Macr
68. confirmation CB FreezeND This subroutine defines which assumptions decision variables or forecasts will hold their worksheet values during a simulation Tip Before calling this subroutine activate a worksheet and reset the simulation You must have at least one assumption decision variable or forecast in the list of cells to freeze oe enable Otherwise CB MacroResult returns an error 138 Crystal Ball Macro Calls To freeze cells build a list of cells to be frozen and then use the cbFrzSetList constant to actually freeze the list To unfreeze cells and freeze different ones add all frozen cells to the list of frozen cells unfreeze them and then clear the list before freezing new cells Note Itis not possible to select a range of cells in the format Range D6 E527 and add that to the list of frozen cells You must select and add each cell individually as shown in CB FreezeND Example on page 140 To freeze a large number of cells the most efficient way is to enumerate through all of the assumptions decision variables and forecasts on the sheet you wish to remove from the simulation and then freeze the Crystal Ball data in those cells one at a time You should be able to refer to the example code for CB EnumAssum for example to see how the enumeration should work When you are done with the simulation you will need to unfreeze the Crystal Ball data in the same way Table 81 CB FreezeND P
69. constant if set to True includes the specified items in the output report For Valuel A string containing an String n a Specifies custom cbTwoDPercentCustom Excel range that holds percentile values to desired percentile values The values must be entered into Excel as numbers not formatted as percentages can be decimals analyze CB TwoDSimulationND Example 1 This example resets the Crystal Ball simulation selects a target forecast in cell Al resets assumptions to the uncertainty list adds cells to the variability list specifies the number of trials for the uncertainty and variability simulations specifies that only the target forecast chart should display sets ouput options sets the maximum number of uncertainty simulations to display in the ouput report and overlay chart to 75 and then runs the tool CB ResetND CB TwoDSimulationND 239 Select target forecast A1 Select lt Al must contain a forecast CB TwoDSimulationND cbTwoDChooseTarget Set all assumptions to the uncertainty list CB TwoDSimulationND cbTwoDChooseAssum cbTwoDAssumClearList Set cells D3 and F9 to the Variability list D3 Select CB TwoDSimulationND cbTwoDChooseAssum cbTwoDAddAssumVar F9 Select CB TwoDSimulationND cbTwoDChooseAssum cbTwoDAddAssumVar Set the outer uncertainty simulation loop to 500 trials CB TwoDSimulationND cbTwoDOuterSimTrials 500 Set the inner variab
70. correlation value for that pair Sub EnumCorr2 CB CheckData Dim asmlAddress As String Dim asm2Address As String Dim corrValue As Variant Dim count As Variant Dim initialCount As Variant initialCount CB EnumCorrelation asmlAddress asm2Address corrValue count initialCount CB EnumCorrelation 119 While count gt 0 Cells initialCount count 1 5 asmlAddress Cells initialCount count 1 6 asm2Address Cells initialCount count 1 7 corrValue count CB EnumCorrelation asmlAddress asm2Address corrValue Wend End Sub CB EnumCorrelation Related Calls Name Description CB EnumAssum Enumerates assumption cells for all open workbooks CB GetAssum Retrieves information for a specific assumption cell CB EnumDecVar This function enumerates decision variable cells for all open workbooks This command is useful for determining what decision variables have been defined for the open worksheets You can then call CB GetDecVar for each decision variable to retrieve specific information for example range minimum or maximum Table 63 CB EnumDecVar Returned Data Type Returned Value Returned Data Type The absolute cell reference of the next decision variable in the format workbook sheet A Variant 1 For best results call CB CheckData once at the beginning of an enumeration to reset the sequence of decision variables You should also call CB CheckData
71. distribution index and a parameter index it returns the value of the locked parameter if it is locked or cbParmUndefined if the parameter is not locked but can be locked or if the distribution and parameter combination is invalid for parameter locking Table 125 CB GetLocktFitParm Returned Data Type Returned Value Returned Data Type A boolean indicating whether locking is On True or Off False for the distribution or the Variant actual value of the locked parameter or coParmUndefined if the parameter is not locked or cannot be locked CB GetLockFitParm has the parameters shown in Table 126 Table 126 CB GetLockFitParm Parameters Parameter VBA Data Type Value Description Dist Integer Distribution name Indicates the distribution constants as listed in for locked parameter Table 53 Valid information distributions are gamma lognormal Student s t Weibull binomial and hypergeometric ParameterIndex Integer See Table 53 Valid Returns the locked value Optional distribution and parameter setting for the specified 170 Crystal Ball Macro Calls combinations are e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter distribution parameter combination If the value has been cleared or the combination is not valid cbParmUndefined is returned Parameter VBA Data
72. if False does not display filtered out values boolean cbScatterShowLinearRegressionCoef 21 ficients If True displays the slope and Y intercept for the linear regression line on each plot if False does not display this information Table 153 following lists named constant and index values for the Value parameter Table 153 CB ScatterPrefsND Value Parameter Values Required Integer Used With Specified Values of Index For Index 2 3 Integer Named Constant Value Index Value cbScatterAddSelectedVar 1 Description Adds selected variable to scatter chart For Index 2 3 Integer cbScatterRemoveSelectedVar 2 Removes selected variable from scatter chart For Index 2 3 Integer cbScatterRemoveAllVars 3 Removes all variables from scatter chart For zndex 6 Integer cbScatterView 1 Plots each selected assumption or forecast against a target specified with Index 5 For zndex 6 Integer cbMatrixView 2 Plots each selected assumption or forecast against every other selected variable For zndex 9 Integer cbScatterPointSymbolRectangl 1 e Draws rectangular scatter points For zndex 9 Integer cbScatterPointSymbolCircle 2 Draws circular scatter points For zndex 9 Integer cbScatterPointSymbolTriangle 3 Draws triangular scatter points For zndex 9 Integer cbScatterPointSymbolDiamond 4 Draws diamond shaped scatter points
73. included Otherwise only parameter values and assumption charts appear cbBftRun Integer 20 Runs the Batch Fit tool 48 Crystal Ball Macro Calls Named Constant Value VBA Data Type Index Value Description cbBftUseDistLocking Integer 21 Sets the Batch Fit tool to use parameter locking the same as checking Lock Parameters on the Fitting Options panel of the Batch Fit wizard cbBftOutputGoodnessOfFitAllSt Integer 22 Used with Va1ue1 to indicate ats that all statistics should appear when a goodness of fit report is produced When set to True this is the same as checking Show All Goodness of Fit statistics on the Output Options panel of the Batch Fit wizard cbBftFitDistLockParam Integer 23 Used with Value1 Value2 Value3 and Value4 to specify which parameter to lock and which value to use cbBftFitDistLockParam Clear Integer 24 Used with Value1 and Value2 to specify which parameter to clear Table 11 CB BatchFitND Value1 Parameter Optional Variant Related Value Named Constant Value VBA Data Type Index Value Description For Index 1 A cell reference with Variant n a Specifies the range of cbBftinputRange format data to use for fitting Range A1 C300 or A1 C300 For Index 2 cbBftInputRows Integer 1 Indicates that data cells cbBftInputOrientation are in rows For Index 2 cbBftInputColumns Integer 2 Indicates that data cells cbBftInputOrientation are in columns
74. lt gt Set R Range S Range B2 Offset t Value s tet xl S CB EnumAssum Wend CB EnumAssum Related Calls Name Description CB EnumDecVar Enumerates decision variable cells for all open workbooks CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssum Retrieves information for a specific assumption cell CB GetAssumPercent Returns percentile for an assumption cell 116 Crystal Ball Macro Calls CB EnumChart This function returns the unique name ofthe next chart ofthe specified type The string returned is the full path of the chart You can then use other window and chart handling calls to manage the enumerated charts Table 59 CB EnumChart Returned Data Type Returned Value Returned Data Type The path and name of the next chart of that type ChartlD in the format Current Results String Sensitivity Charts Charts xls Sensitivity Chart 1 For best results call CB CheckData once at the beginning of an enumeration to reset the sequence of charts You should also call CB CheckData each time you add or delete data This call operates only on current results and not restored results If the returned string is empty either all charts ofthat type have been enumerated or there were no charts of that type to enumerate You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumChart has only on
75. obtaining results OptRuntime OptCounters This class is the set of optimization counters You can use its members to count simulation iterations Efficient Frontier test points feasible solutions and more OptRuntime OptSolution This class represents a single solution in an optimization where a solution is a set of values for decision variables and their associated result values Result values can be obtained for objectives requirements and constraints OptRuntime OptVarStatistics This class represents optimization variable statistics These summarize the statistics for a single optimization variable in the current optimization They are based upon the selected statistics filter OptRuntime OptVarSolutionFilter This class represents the optimization variable statistics filter The statistics filter limits the set of solutions that affect the optimization variable statistics OptRuntime ResultsWindow This class represents the OptQuest Results window Its methods and properties control the display of optimization results OptRuntime RuntimeEfficientFrontier This class determines ifan Efficient Frontier analysis was run and provides a variety of runtime information about test points and results Efficient Frontier allows users to create a variable list of constraint and requirement right hand side values using a list of test points OptQuest Developer Kit Use and Structure 273 OptRuntime TestPointinfo The methods and
76. opens the Batch Fit wizard CB ResetND CB BatchFit CB BatchFit Related Calls Name Description CB BatchFitND Runs the Batch Fit tool without displaying dialogs CB GetBatchFitOption Returns current settings for the Batch Fit tool CB BatchFitND 46 The Batch Fit tool helps you define assumptions when you have historical data for a number of variables The tool automatically selects which probability distribution binomial normal triangular uniform and so on best fits each series of historical data and provides you with the parameters to use in your model Batch Fit can also provide a table of goodness of fit statistics and a correlation matrix calculated between the historical data This call runs the Batch Fit tool and displays results without using a dialog Note Before calling CB BatchFitND reset the Crystal Ball simulation 46 Crystal Ball Macro Calls 00000 Table 9 CB BatchFitND Parameters Parameter Index Required Required VBA Data Type Integer Table Table 10 Value1 Optional Variant Table 11 Value2 Optional Variant Table 12 Value3 Optional Variant Table 13 Value4 Optional Variant Table 10 CB BatchFitND Index Parameter Required Integer Named Constant Value cbBftInputRange VBA Data Type Integer Index Value Description Used with Value to select the location of the data series
77. optionally specific parameters CB SetFitRange Specifies the data range to be used as input for CB Fit CB GetFore This function retrieves information for a specific forecast cell Note For best results call CB CheckData before calling this function to ensure the latest data values are used Table 115 CB GetFore Returned Data Type Returned Value Returned Data Type The specified forecast data Variant 162 Crystal Ball Macro Calls Table 116 CB GetFore Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the desired forecast cell Index Integer See Table 117 Retrieves information for a specific forecast cell using the values in Table 117 The following table Table 117 shows values available for the Index parameter Table 117 CB GetFore Index Parameter Values Required Integer Named Constant Value cbForName Index Value Description Returns the forecast name cbForUnits Returns the forecast units cbForAutoOpen Returns whether Crystal Ball displays the forecast window automatically 0 no 1 yes cbForOpenWhen Returns when Crystal Ball displays the forecast window 0 when running cbOpnWhenRunning 1 when stopped cbOpnWhenStopped cbForPrecision Returns whether Crystal Ball uses precision control O no 1 yes cbForPrecisionAbsolute Returns what kind of
78. ranking cbDataAnalysisRanking method for distribution Method fitting See Table 77 for constants For Index 13 True or False boolean n a Indicates whether rank cbDataAnalysisGenerate correlations between CorrelationMatrix forecast charts should be displayed in a matrix True generate matrix For Index 14 True or False boolean n a Indicates whether a cbDataAnalysisRunOnAll simulation is run on all Models open workbooks at the same time the selected data is analyzed True run the simulation on all open workbooks CB DataAnalysisND Example This example resets the Crystal Ball simulation and fits all distributions to a columnar data set in cells B1 through D100 including a header row Forecast charts automatically appear when the simulation runs They are fitted to a distribution The selected ranking method is Chi square The last line of code runs the Data Analysis tool CB ResetND Select data in cells B1 through D10 CB DataAnal 1 lysisND cb CB DataAnalysisND cb cbDataAnalysisDataInColumns CB Da Automatically CB Da Fit CB Da Select the Ch CB Da taAnalysisND cb open taAnalysisND cb to distributio taAnalysisND cb taAnalysisND cb Set input range orientation DataAnalysisl n DataAnal DataAnal DataAnalysisSelectData Input range has headers DataAnal forecast charts lysisSelectHeaders lysisA
79. select the corresponding forecast cell CB FormatPrefs Example This example runs a simulation of 500 trials selects a forecast cell B7 and then opens the Format Preferences dialog for the forecast in B7 CB Simulation 500 Range B7 Select CB FormatPrefs CB FormatPrefs Related Calls Name Description CB ChartPrefs Sets chart preferences for the selected forecast or assumption using a dialog CB ChartPrefsND Sets chart preferences for the selected forecast or assumption without a dialog CB FormatPrefsND Sets format preferences for the selected forecast without a dialog CB FormatPrefsND This subroutine sets format preferences for the forecast corresponding to the selected cell without using the Chart Preferences dialog The defaults are the current settings on the Axis tab of the Chart Preferences dialog Select a forecast cell before calling this subroutine to change the format preferences for a single forecast If you call this subroutine to change a single forecast chart A11 is False when no forecast cell is selected CB MacroResult returns cbErrNoForecastInCell See the Oracle Crystal Ball User s Guide for more information on how to format forecast charts CB FormatPrefs 135 Table 78 CB FormatPrefsND Parameters Parameter Index VBA Data Type Integer Value See Table 79 for values Description Specifes which forecast chart Axis preference to change Values appear in Table
80. selected cells CB CopyDataND 74 This subroutine stores a range definition for later use by CB PasteData which pastes all current Crystal Ball data of the selected type from the range stored by CB CopyDataND You can use CB CopyDataND with CB PasteData to quickly set up rows or columns offorecasts assumptions with similar distribution types or decision variables with similar bounds The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts This call has one parameter DataType described in Table 26 Table 26 CB CopyDataND DataType Parameter Integer Required Named Constant Value Index Value Description cbCelAssum 1 Copies only assumption cell data cbCelFore 2 Copies only forecast cell data Crystal Ball Macro Calls Named Constant Value Index Value Description cbCelDecVar 3 Copies only decision variable cell data Use this subroutine when the data range to copy has multiple Crystal Ball data types within the range This subroutine compared to CB CopyData pastes only the specified data type from a range with mixed cells If a range contains different Crystal Ball data types assumptions decision variables and forecasts then Crystal Ball will only copy the data type you specify with the DataType parameter Note Before calling this subroutine select a cell or cell range containing Crystal Ball data CB CopyDa
81. that cell as the target forecast for a sensitivity chart creates and names the sensitivity chart indicates the sensitivity should be shown as Contribution to Variance limits display to the four most sensitive assumptions with sensitivities greater than 0 1 and finally opens the chart CB Simulation 1000 Range B2 Select CB SensPrefsND cbSenTargetFore CB SensPrefsND cbSenTitle My Sensitivity Chart CB SensPrefsND cbSenMeasure cbMesContributionToVar CB SensPrefsND cbSenDisplayOnlyHighest True 4 CB SensPrefsND cbSenDisplayGreaterThan True 0 1 CB OpenSensitiv 212 Crystal Ball Macro Calls CB SensPrefsND Related Call Name Description CB SensPrefs Opens the Sensitivity Preferences dialog for the selected sensitivity chart CB SetAssum This function changes attributes for an assumption without redefining the assumption using CB DefineAssumND Before you call this function the assumption must exist Table 159 CB SetAssum Returned Data Type Returned Value Returned Data Type Whether the function was successful Variant Table 160 CB SetAssum Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to the assumption cell with the data to change Index Integer See Table 161 Changes the assumption name and truncation points according to Value Value Variant See Table 162 Works with Index to specify an assumption name a
82. the selected sensitivity chart CB OpenTrend on page 189 Opens the selected trend chart CB PasteData on page 190 Pastes assumptions decision variables or forecasts into selected cells CB Reset on page 191 Resets the current simulation after prompting CB ResetND on page 192 Resets the current simulation without confirmation CB RestoreResults on page 193 Restores simulation results from a file using a dialog CB RestoreResultsND on page 193 Restores simulation results from a file without a dialog CB RunPrefs on page 194 Sets Crystal Ball run preferences using a dialog CB RunPrefsND on page 195 Sets Crystal Ball run preferences without a dialog CB RuntimeMode on page 200 Hides the Crystal Ball toolbar and menus 30 Crystal Ball Developer Kit Overview Name CB SaveResults on page 201 Description Saves current simulation results using a dialog CB SaveResultsND on page 202 Saves current simulation results without a dialog CB ScatterPrefs on page 202 Opens the Scatter Preferences dialog for the selected scatter chart CB ScatterPrefsND on page 203 Sets preferences for the specified scatter chart CB SelectAssum on page 207 Selects all assumptions in the current spreadsheet CB SelectChart on page 208 Selects the chart with the specified chart ID CB SelectDecVar on page 209
83. this call returns a cbErrNoSelection error for CB MacroResult Table 151 Parameters for CB ScatterPrefsND Parameter VBA Data Type Description Index Integer Works with Va 1ueto set scatter chart preferences For named constant and index values see Table 152 Value Integer Works with Indexto set scatter chart preferences For named constant and index values see Table 153 Table 152 following lists named constant and index values for the Index parameter Table 152 CB ScatterPrefsND Index Parameter Values Required Integer Named Constant Value Index Value Description cbScatterTitle 1 Defines the scatter title according to the supplied string value title text cbScatterManageFore 2 Adds or removes the selected forecast to or from the chart according to Value CB ScatterPrefsND 203 Named Constant Value cbScatterManageAssum Index Value Description Adds or removes the selected assumption to or from the chart according to Value cbScatterSetTarget If True sets the target value required for Scatter View if False clears it cbScatterViewType Specifies the scatter view type according to Value cbScatterPlotSize Specifies the scatter plot size with a value from 1 10 1 is the smallest plot and 10 is the largest cbScatterDrawPoints If True displays scatter points if False does not display them cbScatterPointSymbol Specifies the scatter poin
84. to all forecasts True or just the selected forecast cell False The default is False If this parameter is set to False and the selected cell contains no forecast CB MacroResult returns cbErrNoForecastinCell You can specify one or two of Min Max and Certainty If you specify all three Crystal Ball uses Min and Max to determine the certainty and ignores the entered Certainty value If Min or Max is set to a value other than Infinity or Infinity the certainty grabber is locked at the indicated value If either Min or Max is set to Infinity or Infinity the certainty grabber is not locked there 224 Crystal Ball Macro Calls CB SetRange Example 1 This example runs a simulation of 1000 trials selects cell B7 sets the certainty range to 51 and applies it only to the forecast in cell B7 CB Simulation 1000 Range B7 Select CB SetRange 51 CB SetRange Example 2 This example runs a simulation of 1500 trials sets the certainty range to between negative infinity and 1000 and applies this certainty range to all forecasts CB Simulation 1500 CB SetRange cbMinusInfinity 1000 True CB SetRange Related Call Name Description CB Simulation Runs a Crystal Ball simulation CB Shutdown If Crystal Ball is loaded into Excel this function closes Crystal Ball without closing Excel It returns True when Crystal Ball is successfully unloaded Table 176 CB Shutdown Returned Data Type
85. type of Variant CB GetCorrelation e To correct a documentation error the first parameter is now named AssumReference with a data type of Variant e The Row parameter data type is now Long CB GetDecVar e To correct a documentation error the first parameter is now named DecVarReference with a data type of Variant e A new constant is added for the Index parameter cbDecFrozen 6 e Starting with Crystal Ball 11 1 1 0 00 the cbDecType 4 constant now returns five types Continuous 0 Discrete 1 Binary 2 Category 3 Custom 4 e Also a new constant cbDecCustomData 7 is added for the Index parameter for use when cbDecType 4 indicates a Custom 4 type 256 Changes from Previous Versions CB GetFitParm A fourth Index value is added to support the 7 x and 11 x beta distribution The parameters for beta have changed since 2000 x 5 x A fourth Index value is added to support the 7 x and 11 x beta distribution The extreme value constant is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by coDfaMinExtreme and coDfaMaxExtreme in later versions of Crystal Ball 1 A new distribution type betaPERT cbDfaBetaPert is added in Crystal Ball 7 3 CB GetFore To correct a documentation error the first parameter is now named ForeReference with a data type of Variant The Index parameter has these constant changes o cbForWindowSize 3 is obsolete and has been re
86. when Crystal Ball is first installed is False However the following alternatives can be used to activate autoloading using dialogs instead of the CB SetCBAutoLoad call e Start the Crystal Ball Application Manager and check or uncheck Automatically launch Crystal Ball when Excel starts e Open the Excel COM Add ins dialog and check or uncheck Crystal Ball For more information on these alternatives see Starting Crystal Ball in the current Crystal Ball Installation and Licensing Guide No matter which alternative you use the same setting appears in either of the other two alternatives including the CB SetCBAutoLoad call The autoload setting is persistent once set it remains set until one of the alternatives is used to change it 214 Crystal Ball Macro Calls Table 163 CB SetCBAutoLoad Parameter Parameter autoLoad VBA Data Type boolean Named Constant Value True or False Description True sets Crystal Ball to autoload each time Excel starts False deactivates autoloading CB SetCBAutoLoad Example This code sets Crystal Ball to automatically start when Excel starts CB SetCBAutoLoad True CB SetCBAutoLoad Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is currently loaded within Excel CB GetCBAutoLoad Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Excel opens CB Shutdown
87. whether percentiles are indicated by a percent sign 10 or by a P before the value P10 True uses the P and False uses the sign For Index 49 cbRunSaveAssumptionValues Boolean True or False True saves assumption values for later analysis such as sensitivity analysis False discards them For Index 50 cbRunLeaveOpenOnReset Boolean True or False True leaves the CB Control Panel open when a simulation is reset False closes it For Index 51 cbRunUserMacros Boolean True or False Indicates whether or not to run user defined macros True runs them and False does not run them For Index 52 cbRunCapMetrics Boolean True or False Sets whether the Ul should display capability metric related information True shows metrics and False does not show capability metrics For Index 53 cbRunCapMetricsShort Boolean True or False Determines if the underlying forecast data should be considered short or long term True short term data and False long term data For Index 54 cbRunCapMetricsShift A numeric value indicating short term long term shift Sets the shift value used for calculating Zst and Zit the default shift used in the UI is 1 5 For Index 55 cbRunCapMetricsCalcType Integer Oor1 Determines if the capability metrics should be calculated from the fitted curve or the data O calculate from fitted curve and 1 calculate from data
88. with version 11 1 1 0 00 the lognormal distribution has three parameters instead of two If this call is used in a model that was created in an earlier version of Crystal Ball the third parameter has a value of 0 The following table shows Criterion parameter values used to specify which fitting statistics to return Table 77 CB Fit Criterion Parameter Values Required Integer Named Constant Value Index Value Description cbFitChiSquare 1 Returns the chi square statistic cbFitChiSquareP 2 Returns the chi square statistic p value cbFitKolmogorovSmirnov 3 Returns the Kolmogorov Smirnov statistic cbFitAndersonDarling 4 Returns the Anderson Darling statistic CB Fit 133 Named Constant Value Index Value Description cbDfaAutoSelectRanking Method 5 Automatically selects a ranking method depending on characteristics of the data CB Fit Example 1 This example selects a range of data in column D and then calls CB Fit in a For loop The loop fits the triangular distribution to the range of data and prints the results of each possible test to the spreadsheet next to the original data in cells E4 to E7 CB SetFitRange Range D4 D104 For i 1 to 4 Range E3 Offset i Value CB Fit cbDfaTriangular i Next i CB Fit Example 2 This example selects a range of data in column D and then calls CB Fit in a For loop using the If loop to eliminate the distribution indices that do not
89. work with CB Fit The loop fits each distribution to the range of data saving the best distribution index in bestdist and the corresponding Anderson Darling p value in bestfit CB SetFitRange Range D4 D104 For i 0 To 23 TE i 2 O0r i 3 Ori 7 Or i 10 Or 1 11 Or 1 16 Or i 17 Or i 21 Or i 22 Then Else result CB Fit i 4 True If i 0 Then bestfit result If bestfit gt result Then bestdist i bestfit result End If End If Next 1 CB Fit Related Calls Name Description CB DefineAssum Defines an assumption in the selected cell using a dialog CB DefineAssumND Defines an assumption in the selected cell without using a dialog CB GetFitParm Returns the value of the specified distribution parameter for the last CB Fit call CB GetLockFitParm Returns whether a distribution and optionally specific parameters have locked values for fitting purposes 134 Crystal Ball Macro Calls Name Description CB LockFitParm Sets parameter locking for distributions and optionally specific parameters CB SetFitRange Specifies the data range to use as input for CB Fit CB FormatPrefs This subroutine opens the Axis tab of the Chart Preferences dialog so you can change the axis label preferences axis scale and number formatting for the selected forecast Note Before calling this subroutine to change the axis label preferences for a particular forecast chart
90. xla in the Crystal Ball installation folder e Toledo Gas xls in the Examples folder a sample spreadsheet with commented code so you can follow how the Predictor Developer Kit was used to create several sample time series forecasts e CB Com Devkit chm in the Docs folder an online help file that describes the methods and properties within each class of the Predictor Developer Kit see CB Com Devkit chm on page 274 for more information Developer Kit Use and Structure This section gives specific requirements for installing and using the Predictor Developer Kit It also summarizes the structure of the Developer Kit and introduces CB Com Devkit chm a help file that serves as an online reference to the classes methods properties and other elements of the Predictor Developer Kit Specific Requirements for Use If you have a license to run Oracle Crystal Ball Fusion Edition Crystal Ball Decision Optimizer or Oracle Crystal Ball Enterprise Performance Management Fusion Edition you can use the Predictor Developer Kit and run applications built with it The following sections outline specific requirements for its installation and use Installing the Predictor Developer Kit The Predictor Developer Kit is automatically available when you install any of the Crystal Ball products version 11 1 1 3 00 or later and is immediately available for your use For installation instructions see the current Oracle Crystal Ball Installation
91. you can use the OptQuest Developer Kit and run applications built with it The following sections outline specific requirements for its installation and use Installing the OptQuest Developer Kit If you are licensed to use OptQuest as part of Crystal Ball the OptQuest Developer Kit is automatically available when you install Crystal Ball and is immediately available for your use For installation instructions see the current Crystal Ball Installation and Licensing Guide Microsoft NET Framework Version The OptQuest Developer Kit has been tested to run properly with Microsoft NET Framework Versions 2 0 3 0 and 3 5 You can force the OptQuest Developer Kit to run against a specific 270 Using the OptQuest Developer Kit version of the NET Framework using an application configuration file in the form of lt appname gt exe config placed in the folder of the application s executable The following section forces the OptQuest Developer Kit code to run against Microsoft NET Framework 2 0 lt configuration gt lt startup gt lt supportedRuntime version v2 0 50727 gt lt startup gt lt configuration gt You might also want to run against a specific version of Microsoft Excel In that case appname would be excel and you would be modifying a file called excel exe config 64 bit Operating System Execution Currently OptQuest Developer Kit applications must execute as 32 bit applications when running on 64 bit capable op
92. 0 5 5 5 compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball Criterion constant cbFitChiSquareP 2 has been added back in Crystal Ball 11 1 1 0 00 to show the Chi square p value A new optional boolean parameter pValue is added to display p values instead of statistics when set to True Changes to Existing Calls 255 e Starting with Crystal Ball 11 1 1 0 00 discrete distributions can be used for fitting and Crystal Ball will also select distributions and a ranking method automatically when requested The following new Dist parameter constants support new distribution fitting options cbDfaAutoSelectDist 50 coDfaAllContinuous 51 cbDfaAllDiscrete 52 and cbDfaAllDistributions 53 A new Criterion parameter constant cbDfaAutoSelectRanking Method 5 has been added to support automatic selection of the ranking method CB Freeze and CB FreezeND e These calls replace CB FreezeAssum and CB FreezeAssumND This change reflects the new functionality in Crystal Ball versions later than 2000 5 5 5 that can freeze decision variable and forecast cells as well as assumptions CB GetAssum e To correct a documentation error the parameter name AssumRef is changed to AssumReference to match the code The data type is now Variant CB GetAssumPercent e The data type of the Percent parameter is now Double CB GetCertainty e The first parameter is now named ForeReference with a data
93. 000 into cell M6 In a macro you can enter CB Simulation 1000 Range M6 Value CB GetCertainty Range B7 15000 CB GetCertainty Example 2 This example before a simulation displays VALUE in the cell After a simulation it displays the certainty of the forecast in B7 being less than or equal to 15 000 In a worksheet cell you can enter CB GetCertaintyFN B7 15000 152 Crystal Ball Macro Calls CB GetCertainty Related Calls Name Description CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssumPercent Returns percentiles for assumption cells CB GetForePercent Returns percentiles for a specific forecast CB GetForeStat Returns statistics for forecast cells CB Simulation Runs a Crystal Ball simulation CB GetCorrelation This function returns the correlation coefficient defined between two assumption cells Note For best results call CB CheckData before calling this function to ensure the latest data values are used Table 101 CB GetCorrelation Returned Data Type Returned Value The correlation coefficient of the two assumptions Returned Data Type Variant If a correlation between the assumptions wasn t defined this function returns the value 2 Table 102 CB GetCorrelation Parameters Parameter VBA Data Type AssumReference Variant Value Description In a macro Range B3 Points to one of the correlated assumption cells
94. 1 CB GetCertainty 151 256 CB GetCertaintyEN 151 CB GetCorrelation 153 256 CB GetDataAnalysisOption 154 CB GetDecisionTableOption 156 CB GetDecVar 158 256 CB GetExcel2007ForegroundMode 160 CB GetFitParm 160 257 CB GetFore 162 257 CB GetForeData 165 CB GetForePercent 166 CB GetForePercentFN 166 CB GetForeStat 167 257 CB GetForeStatFN 167 294 Index G L MN OP R S TU VW CB GetLockFitParm 170 CB GetRunPrefs 172 257 CB GetRunPrefsEN 172 CB GetTwoDSimulationOption 173 CB GetVersion 176 258 CB GetWorksheetVersion 178 CB IsCBObject 179 258 CB Iterations 180 CB IterationsEN 180 CB LockFitParm 181 CB MacroResult 182 CB MacroResultDetail 184 CB ND 249 CB OpenChart 186 CB OpenFore 187 CB OpenSelection 188 CB OpenSensitiv 189 258 CB OpenTrend 189 258 CB OptRuntime 279 CB OptSetup 279 CB OptSetup Show 279 CB PasteData 190 258 CB Reset 191 CB ResetND 192 CB RestoreResults 193 CB RestoreResultsND 193 CB RunPrefs 194 CB RunPrefsND 195 258 CB RuntimeMode 26 200 CB SaveResults 201 CB SaveResultsND 202 CB ScatterPrefs 202 CB ScatterPrefsND 203 CB SelectAssum 207 CB SelectChart 208 CB SelectDecVar 209 CB SelectFore 209 CB SensPrefs 210 CB SensPrefsND 210 259 CB SetAssum 213 259 CB SetCBAutoLoad 214 CB SetCBWorkbookPriority 215 CB SetDecVar 216 259 CB SetExcel2007ForegroundMode 218 CB SetFitRange 219 CB SetFore 219 260 CB SetRange 223 A B C D E
95. 165 formats forecast windows 135 formats forecast windows 135 freezing data cells 138 freezing data cells 138 function 21 G global macros 283 H help developer kit 274 how this manual is organized 20 how to use the Developer Kit 24 l important classes OptQuest Developer Kit 271 installing the OptQuest Developer Kit 270 installing the Predictor Developer Kit 286 iterations 180 L listing charts 117 M macro results 182 184 macros global 283 user defined 279 macros user defined 26 managing charts 35 Microsoft NET Framework 270 287 multiple simulations starting 229 stopping 231 M N OP R S TU VW N namespace Predictor Developer Kit 287 namespace OptQuest Developer Kit 271 0 On Error GoTo 278 On Error Resume Next 278 opening CB forecast windows 187 charts 186 188 189 OptDFevKitRuntimeSample xls 276 optimization runtime classes 272 optimization setup classes 271 optimizations coding 277 OptQuest code development 274 OptQuest Developer Kit 269 270 installation 270 OptQuest Developer Kit classes important 271 OptQuest Developer Kit namespace 271 OptQuest Developer Kit sample 276 OptQuest development environment 274 OptQuest development resources 274 OptQuest wizard 279 OptQuest constraints and macros 283 OptRuntime class 273 OptRuntime OptCounters class 273 OptRuntime OptSolution class 273 OptRuntime OptVarSolutionFilter class 273 OptRuntime OptVa
96. 6 vos 44444044518 dO EORR EC dE ER A 285 VIA Ths BE iuo kaw sew acne A qe haue sous 286 What This Kit Includes sink coho 5 deh b bea ede i GR ashes 6 dened kevin 286 Developer Kit Use and Structure TETE perdais 286 Specie Beouseronis Jor Use AA 286 xvi Contents Predictor Developer Kit Namespace usse emer mr RR S rp RES 287 Important Predictor Li rs odore lo 9 Ide c o REOR CC ed 287 Developing Time peries Porecashug Code cosido 290 NUBE AAA 283 Contents xvii xviii Contents Welcome In This Chapter About the Oracle Crystal Ball Developed tes 19 Who Should Use the Crystal Ball Developer Kilo o A tonne nct bn nnns th wee 20 What You Will NEET ora ene aed a ad de A 20 How This Mantal is Organized csr ai arte ae a ee ee ee Ud d 20 brc DEPO mU 21 Technica Suppan ana MoE cose eti Sor Ie ES SPI pER E puppe MUN UudE 21 About the Oracle Crystal Ball Developer Kit Welcome to the Developer Kit for Oracle Crystal Ball Fusion Edition Using the Crystal Ball Developer Kit you can automate and control Crystal Ball simulations from within a Visual Basic for Applications VBA program This opens up a whole range of possibilities e Running multiple simulations to test different sets of assumptions automatically e Integrating Crystal Ball with other software tools e Creating turnkey applications that shield users from program intricacies e Building custom reports or automate post simulation analysis e
97. 7 Table 37 Index cbRptChooseDecVar Value1 Values Optional Integer Named Constant Value Index Value Description cbChdaAll 1 Includes all decision variables cbChdChosen 2 Includes chosen decision variables Include a statement with this constant after added decision variables cbChdAdd 3 Adds the decision variable in the selected cell to the list of chosen decision variables cbChdClearList 4 Clears the list of chosen decision variables With Index set to cbRptChooseOverlay cbRptChooseTrend or cbRptChooseSensitivity you can specify which individual charts to include in a report when charts are selected with CB SelectChart see Table 38 Table 38 For Index cbRptChooseChartype Value1 Values Optional Integer Named Constant Value Index Value Description cbChartAll 1 Includes all charts of the specified type cbChartOpen 2 Includes all open charts of the specified type cbChartChosen 3 Includes chosen charts of the specified type cbChartAdd 4 Adds the selected chart to the list of chosen charts cbChartClearList 5 Clears the list of chosen charts CB CreateRptND 87 With Index set to coRptDefinedType you can indicate which predefined report type to use see Table 39 Table 39 For Index cbRptDefinedType Value1 Values Optional Integer Named Constant Value Index Value Description cbRptFull 1 Report format is the predefined ful
98. 79 1 cbFmtFormatType 2 cbFmtUnderlying 3 cbFmtCommas 4 cbFmtDecimalPlace Value Variant See Table 80 for values Used with the zndex parameter to specify forecast chart Axis preference settings Values appear in Table 80 A11 Optional Variant True applies this option to all forecasts False applies this option only to the selected forecast The default is False The Index parameter Table 79 on page 136 works with the Value parameter to set Axis preferences for forecast charts Table 79 CB FormatPrefsND Index parameter values Required Integer Named Constant Value cbFmtFormatType Index Value Description Sets the number format of the axis labels according to the Value parameter setting cbFmtUnderlying Sets whether to use the underlying cell format for the axis labels according to the Value parameter setting You cannot use any other format preferences unless this option is turned off cbFmtCommas Sets whether to use commas or another thousands separator character indicated in the Windows regional settings in the axis labels according to the Value parameter setting This preference is ignored for scientific notation cbFmtDecimalPlace Sets the number of decimal places to use in the axis labels for fixed and scientific number formats according to the Value parameter setting The value parameter Table 80 works with the Index p
99. 9 CB CellPrefsND ido m es M Boiss abes nis ENT ms 249 MA 2 115 PP 250 COORD daquqaseieqd quacsequiedqiedeqeqaaxeedugadqibasdipaddies 250 Ch ClearDat osx TT IEA RD eee ee eee T 290 CE Rear aS 1 ruta IF db dor Ie Aor PRECOR dee ob Ra REC 250 CB Close Pore ssas rss o eas eee ee ee RU ee eee 250 CB CloseSensitiv Edo E do OR RE dot ard uad dx a ca DO UE do Cra a 250 MH eaa cana rp p E eee AOE ole A ook a CH Copr Data end CE Coen soriana rar eR dre xd detur ed 251 xiv Contents CB CorrelateND mage ee TEME ada e e NS 251 UB eRe 24 ake ERE 231 CLAD sarria ara aaa 251 CB Deline AlParms eres eR cal bee ye 252 CB DEAN ot hn A EA AAA 253 CE Dene eit A tetas bate beds bee Ea3dJc dae Rudd is 253 ns usadas nV RAI re pb Edo eaae acd qe Fes Ebo Rer db ok d 253 CB DefineDecVarND Sees Bass nm os ree aoe 254 CB Deime rore ND uis sau vend Ras dep xx duucxud qq du euge xd gu acad ddp 254 CARENCIAS 2364468 paria aaa eqq deed eig 254 CB EnumDecVar abate A pra E iuge 254 COTA La EUR th we HORIS EA Ad dE 254 MA PeturxedobbkRA Ri DEEREGGU RE RA GG KENN ie 254 Cl needed Ade S p o pod a d b b CCo RE Doc bn i d 255 Chess und CASEN uaa a dace oet de ek de Eae Eder dei nee op ee 256 CA a s ca Y qe vuce dg dese arg xd esq SU bu xar xd pe aqq iru ep 256 LB Gets OPERE cosacos a eaaa pa 256 CB GetCertainty dud sees wre renee abe eee abei 256 dre dum P cH CAE
100. A A A A A AA a 143 NE cQ rini srta ir ai ii di si LAA CB GetBootstrapOpliDfi cusseeceua irata ita do dardos a ee ree er eee tr qus daa rr nee Tee minten LAS A A eser Me iV pi mie uod UauRIiNE es muro LOL CB GetCertainty E ER ica VOL BER OTS A o piss A ce RU waste A tt Adel CR QU Gade pun hace tein RE le 153 A PEREAT PU 154 CB Gotb A A ed eter een duced Me qs 156 A A 158 CB DerExcel2 DO TFOFeP OO MOE siii dora visu ns acia nias bia papilas pins adi arias plain la 160 CB GetFitParm St LOD Ed AA AA AA RT sS IRR Perl A TIT 165 UB BELFOISPOFCBHL c acini a A ERR ER 166 pr iD orar 167 Hake bee E Rer m 170 EB CAEN PGES diets maieniidqebd tas dud dan bagno VERAM E A E Sencha cud qp ed P peaaibnan FARNE 172 Crystal Ball Macro Calls CB GetTwoDSimulationOption a facha odas LE E A pace viden e mud dida xa a 176 CB GetWorksheetVersion ssss tr 178 BRL NOM A A pm V deed REA cu AS CB Iterations 180 CB bol EP IR Sse eene eder ete pene ero iae etn bd ted aed ween tee end eee dane E PETE 181 CB MacroResult eere OTTENUTO UT 182 CB MaeroResultDetall acuuas ciun ean suena oon TUI CB OpenChart 2 ooo 4 186 CB OpenFore
101. B CloseSensitiv on page 250 To close a chart of a specific type by its chart ID use CB CloseChart CB CloseChart on page 71 CB CloseSensitiv Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next sensitivity chart in the workbook and then closes it CB Simulation 1000 CB CheckData Crystal Ball Macro Calls CB SelectChart cbChtSensitiv CB EnumChart cbChtSensitiv CB CloseSensitiv CB CloseSensitiv Related Calls Name Description CB CopySensitiv Copies the selected sensitivity chart to the clipboard CB EnumChart Returns the unique name of the next chart of the specified type CB OpenSensitiv Opens the selected sensitivity chart CB SelectChart Selects the chart with the specified chart ID CB CloseTrend This call closes the selected trend chart If more than one chart is found but one is not selected a chooser dialog appears Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB CloseTrend on page 250 To close a chart of a specific type by its chart ID use CB CloseChart CB CloseChart on page 71 CB CloseTrend Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next trend chart in the workbook and then closes it CB Simulation 1000 CB CheckData CB SelectChart
102. B Enum call follows selects the next sensitivity chart in the workbook and then copies it CB Simulation 1000 CB CheckData CB SelectChart cbChtSensitiv CB EnumChart cbChtSensitiv CB CopySensitiv CB CopySensitiv Related Calls Name Description CB CloseSensitiv Closes the selected sensitivity chart CB EnumChart Returns the unique name of the next chart of the specified type CB OpenSensitiv Opens the selected sensitivity chart CB SelectChart Selects the chart with the specified chart ID CB CopyTrend This call copies the selected trend chart to the clipboard If more than one chart is found but one is not selected a chooser dialog appears 76 Crystal Ball Macro Calls CB CopyTrend Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next trend chart in the workbook and then copies it CB Simulation 1000 CB CheckData CB SelectChart cbChtTrend CB EnumChart cbChtTrend CB CopyTrend CB CopyTrend Related Calls Name Description CB CloseTrend Closes the selected trend chart CB EnumChart Returns the unique name of the next chart of the specified type CB OpenTrend Opens the selected trend chart CB SelectChart Selects the chart with the specified chart ID CB CorrelateND This subroutine defines or updates a correlation coefficient between the assumptions corresponding to two selected cells Ta
103. B ScatterPrefsND cbScatterPointSize 4 CB ScatterPrefsND cbScatterPointColor 2 The next commands draw a linear regression line on top of points width 2 color purple CB ScatterPrefsND cbScatterDrawLines True CB ScatterPrefsND cbScatterLineType cbScatterRegression CB ScatterPrefsND cbScatterLineWidth 2 CB ScatterPrefsND cbScatterLineColor 5 The next commands draw the correlation coefficient in each plot but do not show the regression properties CB ScatterPrefsND cbScatterDrawCorrelationCoefficient True CB ScatterPrefsND cbScatterShowLinearRegressionCoefficients False The next command opens the chart CB OpenChart cbChtScatter CB ScatterPrefsND Related Call Name Description CB ScatterPrefs Opens the Scatter Preferences dialog for the selected scatter chart CB SelectAssum This subroutine selects all assumptions in the current worksheet The desired worksheet must be active selected for Crystal Ball to run this command CB SelectAssum Example This example activates the Model worksheet of the Futura with OptQuest xls workbook and selects all the assumptions in the worksheet Workbooks Futura with OptQuest xls Worksheets Model Activate CB SelectAssum CB SelectAssum 207 CB SelectAssum Related Calls Name Description CB SelectDecVar Selects all decision variables in the current worksheet CB SelectFore Selects all forecasts in the current worksheet
104. CB CloseChart cbChtOverlay CB EnumChart cbChtOverlay CB CloseChart Related Calls Name Description CB CloseAllCharts Closes all open chart windows equivalent to Analyze then Close All CB EnumChart Returns the chart ID of the next chart of the specified type CB OpenChart Opens the selected chart of the specified type CB CloseChart 71 Name Description CB SelectChart Selects the chart with the specified chart ID CB CloseFore This subroutine closes the forecast window for the selected cell The worksheet must be active and a forecast cell selected for Crystal Ball to run this command Note Before calling this subroutine activate a worksheet and select one forecast cell CB CloseFore Example This example activates the Model worksheet of the Futura With OptQuest xls workbook and selects cell C9 a forecast Then it closes the forecast window associated with that cell Workbooks Futura with OptQuest xls Worksheets Model Activate Range C9 Select CB CloseFore CB CloseFore Related Calls Name Description CB OpenFore Opens forecast window for selected cell CB CloseSensitiv 72 This call closes the selected sensitivity chart If more than one chart is found but one is not selected a chooser dialog appears Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see C
105. CelPattern Index Value Description Sets a pattern choice defined by Value Table 21 cbCelColor Sets a color choice defined by Value cbCelNote Turns notes on and off depending on Value cbCelDistMean Sets the value in assumption cells to be the mean of the defined distribution cbCelRangeMidpoint Sets the value in decision variable cells to be the midpoint of the defined range cbCelDistMedian Sets the value in assumption cells to be the median of the defined distribution cbCelRangeMin Sets the value in decision variable cells to be the minimum of the defined range cbCelRangeMax Sets the value in decision variable cells to be the maximum of the defined range The Value parameter values listed in the following table work with the Index2 parameter values to set cell preferences For Index2 values see Table 20 Table 21 CB CellPrefsND Value Parameter Values Variant Required Used With Specified Named Constant or Values of Index2 boolean Value Index Value Description For Index2 1 n a 0 through 17 O specifies no pattern 1 cbCelPattern Integer through 17 specify available patterns For Index2 2 n a 0 to 15 O specifies no color 1 15 cbCelColor Integer specify available colors For Index2 3 True or False n a True turns on notes False cbCelNote Boolean turns off notes For Index2 4 True or False n a For assumption cells True cbCelDi
106. Classes support functionality in the Predictor user interface UI To help you locate appropriate classes class names are designed to reflect the UI Predictor Setup Class Main classes for setting up validating and running Predictor e PredSetup main class interface for setting up and running Predictor e PredSetup PredInputData e PredSetup PredDataAttributes e PredSetup PredMethods e PredSetup PredOptions e PredSetup PredSeries PredSetup This is the top level interface class that provides access to objects to set and define all Predictor settings available through the Predictor wizard user interface The properties of this class enable access to classes that correspond to the wizard panels Input Data Data Attributes Methods and Options The methods of this class enable validation of input data and settings and also provide a method to run the time series forecast PredSetup PredinputData This class provides access to input data properties corresponding to the Predictor wizard Input Data panel This class enables you to control items such as input data range data orientation and headers PredSetup PredDataAttributes This class provides access to data attribute settings corresponding to the Predictor wizard Data Attributes panel This class enables you to control items such as seasonality data screening and outlier detection 288 Using the Predictor Developer Kit PredSetup PredMethods This class provides acces
107. Closes Crystal Ball while leaving Excel open CB Startup Loads Crystal Ball into Excel if possible and indicates when Crystal Ball has been successfully opened CB SetCBWorkbookPriority This subroutine sets the running order for Crystal Ball macros when multiple workbooks are open For example a workbook with aPriority 10 will run before a workbook with aPriority 20 CB SetCBWorkbookPriority runs only at the workbook level and not at the worksheet level For details see Running user defined macros at the end of Chapter 5 in the Oracle Crystal Ball User s Guide Table 164 CB SetCBWorkbookPriority Parameter Parameter aPriority VBA Data Type Long Value An integer of any size usually positive Description Specifies the running priority of user defined macros in a workbook The smaller the positive value the higher the priority CB SetCBWorkbookPriority Example This example assigns a priority of 10 to the workbook Book1 xls CB SetCBWorkbookPriority 215 Application Workbooks Book1 x1s Activate CB SetCBWorkbookPriority 10 CB SetDecVar This function changes certain attributes for a decision variable without redefining the decision variable using CB DefineDecVarND Table 165 CB SetDecVar Returned Data Type Returned Value Returned Data Type Whether the function was successful Variant Before you call this function the decision variable must exist and the s
108. DecSimOption to Integer specify the number of test values to use for the first selected decision variable For Index 3 coDecSimOption coDecNumValuesVar2 2 Used with cbDecSimOption to Integer specify the number of test values to use for the second selected decision variable For Index 3 coDecSimOption cbDecSimrTrials 3 Used with cbDecSimOption to Integer specify the maximum number of trials for each simulation CB DecisionTableND 97 Related Value Named Constant Value Index Value Description For Index 4 cbDecForeOption coDecShowDefinedFore 1 Used following Integer cbDecForeOption the equivalent of the Show Forecasts As Defined dialog setting For Index 4 cbDecForeOption cbDecShowTargetFore 2 Used following Integer cbDecForeOption the equivalent of the Show Only Target Forecast dialog setting For Index 4 cbDecForeOption cbDecHideFore 3 Used following Integer cbDecForeOption the equivalent of the Hide All Forecasts dialog setting Table 48 CB DecisionTableND Value Parameter Optional Variant Related Value Named Constant Value VBA Data Type Description For Index2 A positive whole number Integer Specifies the number of test cbDecNumValuesVar1 or values to use for each selected cbDecNumValuesVar2 Integer decision variable For Index2 cbDecSim Trials A positive whole number Long integer Specifies the maximum number Long Integer of trials for each
109. Detail OldValue Returned Constant Returned Value Description cbErrNone 0 The previous Crystal Ball command worked perfectly cbErrBadValue 1 A parameter had the wrong value 184 Crystal Ball Macro Calls a Returned Constant cbErrNoForecastInCell Returned Value 2 Description The command required a forecast cell to be active the active cell did not contain a forecast cbErrNotReady Crystal Ball has not yet run a simulation so the requested macro cannot be run cbErrNoAssumptionInCell The command required one or two assumption cells to be selected One or more selected cells did not contain assumptions cbErrBadSelector A parameter that was restricted to a small number of integers had a bad value cbErrBadCommand The parm_number parameter had a bad value cbErrUnsavedSheet The operation required all worksheets to be saved but one or more sheets were not saved cbErrNoCBSheets There were no worksheets with Crystal Ball information to save cbErrRestoreResult 10 Restore Results failed cbErrTooManyAssumptions 11 Crystal Ball can store no more assumptions cbErrTooManyForecasts 12 Crystal Ball can store no more forecasts cbErrBadCorrelation 13 One or more correlations were invalid cbErrBadAssumption 14 One or more assumption parameters were invalid cbErrUnexpected 101 An unexpected error
110. E E AE E A ene E E E TIT 72 CE Clos Foe RAMS serenite krada acid ara 72 CB CloseFore Related Calls reddes bes AAA bes gud 72 wii i AN M TC B C loseSenste Example lan rds pex UE KR pU Ro Rae eRe dna 72 CB CloseSensitiv Related Calls RENS eds EE bd ERO m des CIC MMC 73 sie Eo AAA 73 CERA ioe rend Relited Cale pira rada 73 CB CopyData 42s bes is bes sis ea Ri 74 CB CopyData Example M ias P CB CopyData Related Calls daesnuexd A ARA EI A eased d 74 CB CopyDataND ud ads 74 Cpe ee esper o do orae eo p E de oe role tenes 25 CRTR Related Lll rg ARA 75 CE OPET iva ei A a 75 CBLoprsodtier Exstuple ows da e Ped ep dO EI ICE RO CR AAA 75 Contents V CB CopyScatter Related Calls es as LED AAA 76 CB CopySensitiv Example eorr 76 CB CopySensitiv Related Calls n ere e e o4urewtbtbi E addis hehe E E PCHOEPCERE E TM KE 76 CB CopyTrend Example Harm 377 CB CopyTrend Related Calls liu A A aad RR Rd 77 CB CorrelateND bass 1 CE Correlate ND DONDE T 1o oua e sav A e a end qe nae rame 78 CB CorrelateND Example2 T EE TIIE TA TES AE pet d edad ida s 78 CB CorrelateND Example3 seus Kw bes seas sees err ree ee ere 70 CE Coreen Related Call e i
111. E TAE S Ya X ERE 218 CB SetExcel2007ForegroundMode Example 4 2524 ur gn 218 CB SetExcel2007ForegroundMode Related Call m Rn dass x 219 LL Be PUB AA ERE E OIA ERE edSdactRA Y FM dwgds si 219 CR Se nates AAA IGI CR DOLI RC IOS dae 219 Choe aes Related Call 4 24244 AR ROCA ERROR RR GR 219 DOO SUG RM A he ae ae Ge enng Paes 219 See a su ori RR AAA OR Re RR ER re 223 CB SetFore Example 2 A aque qpKeE d dddqies 223 CB SetFore Related Calls rw or er ire ver es lt 223 wid i ro pr cU 2 CB SetRange Examplel rrr rs CB SetRange Example2 edd e ror Bews er ee Cee DEBEO LUE ra dE ORO EON dees de o de oret dod 225 wifi econ iS EA Hoe adweeweses 225 CB Shutdown Example s 22asaktaedesacebes4dezadeeduapasebeeb parade wea 225 CB Shutdown Related Calls be AAA bes T 225 EE MP is 226 CE SR Eee coc ARA 226 CB SimResult Related Calls ates ee T ed pes S 226 PD UML GUI CO CE 226 Ce CIEN EQ 4 one AA RA RR Sd dr ved 228 CB Simulation Example 2 caca ria 228 CB Simulation Related Calls bes Seay err A srai 228 icis 2 464 55 4 esa aed oan ee OE oi bardas nen 229 COSES ESP S ar dered gin DAA ARA 229 CB SingleStep Related Call 445 IAEA ids 229 LED SRM 32 44 4944 94 8971 408 946300 rs A KO e qoe ea E ed eee CBS PERI so qas eas adque aq verd 230 LB Start Mali Related Calle duque qe predial 230 i nu cc
112. Event IterationsCompleted As Long Your code is here End Sub In this signature parameters or arguments are defined as follows e IterationsCompleted Number of iterations completed AfterOptimizationEvent Private Sub PortfolioOptRuntime AfterOptimizationEvent IterationsCompleted As Long Your code is here End Sub 282 Using the OptQuest Developer Kit In this signature parameters or arguments are defined as follows e IterationsCompleted Number of iterations completed EfficientFrontierEvent Private Sub PortfolioOptRuntime_EfficientFrontierEvent TestValue As Double Your code is here End Sub In this signature parameters or arguments are defined as follows e TestValue The Efficient Frontier test value just completed Note Note Returning anything other than a zero from a macro will stop the optimization Constraints and Macros You can set up an OptQuest constraint in the form A1 lt 100 or simular and use CBBeforeSimulation or CBBeforelteration to modify cell A1 If you do this a constant constraint warning appears and warns you that one or more constraints do not appear to contain decision variables that they are marked as constants and therefore no feasible solutions may be found This warning only applies if you don t have a macro that modifies the cell If you are using a macro to change values in the referenced cell you can close the warning and continue with the optimization Then
113. F G H CB Shutdown 225 CB SimResult 226 260 CB Simulation 226 260 CB SingleStep 229 CB StartMultiSimul 229 260 CB Startup 230 CB StopMultiSimul 231 CB TrendPrefs 231 CB TrendPrefsND 232 261 CB TwoDSimulation 236 CB TwoDSimulationND 236 CB WorksheetProtection 241 cells freezing 138 cells CB preferences 60 61 certainties getting CB forecast 151 chart windows 34 charts closing 70 71 72 73 copying 75 76 creating 79 deleting 115 Excel 86 listing 117 managing 35 opening 186 188 189 preferences 202 203 210 231 232 selecting 208 classes important OptQuest Developer Kit 271 optimization runtime 272 optimization setup 271 OptRuntime 273 OptRuntime OptCounters 273 OptRuntime OptSolution 273 OptRuntime OptVarSolutionFilter 273 OptRuntime OptVarStatistics 273 OptRuntime ResultsWindow 273 OptRuntime RuntimeEfficientFrontier 273 OptRuntime TestPointInfo 274 OptSetup 272 OptSetup Constraint 272 OptSetup Decision 272 OptSetup Objective 272 OptSetup OptEfficientFrontier 272 OptSetup OptOptions 272 M N O P R S TU VW OptSetup Requirement 272 Predictor Developer Kit 287 Predictor setup 288 PredResults 289 PredResults PredResultsPreferences 289 PredResults PredResultsWindow 289 PredResults PredSeriesResult 290 PredSetup 288 PredSetup PredDataAttributes 288 PredSetup PredInputData 288 PredSetup PredMethods 289 PredSetup PredOptions 289 PredSetup PredSeries 289 c
114. False boolean n a Indicates whether to cbBftOutputCorrelation correlate assumptions if True assumptions are correlated Value2 can be used to indicate a correlation threshold For Index 16 True or False boolean n a Indicates whether to link cbBftLinkToCorrelationM to the matrix of atrix correlations between the data series if True creates the link For Index 17 True or False boolean n a Indicates whether to cbBftOutputGoodness output a goodness of fit OfFitReport report if True the report is produced For Index 18 True or False boolean n a Indicates whether to cbBftOutputAssumRepor output an assumption t report if True the report is produced For Index 19 True or False boolean n a Indicates whether to cbBftOutputAssumFullSt atistics 50 Crystal Ball Macro Calls include full statistics with an assumption report if True the report contains Related Value Named Constant Value VBA Data Type Index Value Description full statistics including deciles For Index 21 cbBftUseDistLocking True or False boolean n a Indicates whether the Batch Fit tool should use parameter locking if True parameter locking is set the same as checking Lock Parameters on the Fitting Options panel of the Batch Fit wizard For Index 22 cbBftOutputGoodnessOf FitAllStats True or False boolean Indicates whether all statistics should appear when a Goodness of Fit repo
115. LockFitParm Related Calls Name Description CB Fit Fits a specific probability distribution to a selected set of data range of cells CB GetFitParm Returns the value of the specified distribution parameter for the last CB Fit call CB GetLockFitParm Returns whether a distribution and optionally specific parameters have locked values for fitting purposes CB SetFitRange Specifies the data range to be used as input for CB Fit CB MacroResult This function returns information about whether other Crystal Ball macro calls worked correctly Most of the calls described in this document set a result value that CB MacroResult returns CB MacroResult does not clear the result value until another Crystal Ball call changes the value Table 141 CB MacroResult Returned Data Type Returned Value Returned Data Type An error code that indicates what type of error the previous macro call encountered Variant Foralist ofthe named constants and values that CB MacroResult returns see Table 144 In VBA subroutines and functions you can check the returned value against either the named constants or values All returned values are negative integers or 0 if no errors occur 182 Crystal Ball Macro Calls Note This function is for compatibility with the 2000 x 5 x versions of the Crystal Ball Developer Kit CB MacroResultDetail is recommended instead because it provides a wider range of errors CB MacroResult Example Thi
116. Logistic 13 Fits to a logistic distribution cbDfaPareto 14 Fits to a Pareto distribution cbDfaExtremeValue 15 Fits to an extreme value distribution cbDfaNegBinomial 16 Fits to a negative binomial distribution cbDfaHypergeometric Success 17 Fits to a hypergeometric distribution with Success parameter cbDfaMinExtreme 18 Fits to a minimum extreme value distribution 132 Crystal Ball Macro Calls Named Constant Value Index Value Description cbDfaMaxExtreme 19 Fits to a maximum extreme value distribution cbDfaStudentsT 20 Fits to a Student s t distribution cbDfaDiscreteUniform 22 Fits to a discrete uniform distribution cbDfaBetaPert 23 Fits to a betaPERT distribution cbDfaAutoSelectDist 50 Fits to whatever Crystal Ball chooses in the Distribution Gallery as the best type of distribution for fitting cbDfaAllContinuous 51 Fits the data to all continuous distributions in the Distribution Gallery those distributions in which every value in the distribution s range is possible cbDfaAllDiscrete 52 Fits the data to all discrete non continuous distributions in the Distribution Gallery except Yes No cbDfaAllDistributions 53 Fits to all continuous and discrete distributions except Yes No Note ThecbDfaExtremeValue constant is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball Beginning
117. Quest 269 270 developer kit Predictor 285 development environment OptQuest 274 Predictor Developer Kit 290 development resources OptQuest 274 distribution fitting 131 160 170 181 distributions custom 107 fitting 219 296 Index G MN OP R S T U V W E EfficientFrontierEvent 283 enumerating assumption cells 115 118 CB forecast cells 121 charts 117 correlations 118 decision variable cells 120 environment Predictor Developer Kit developmentt 290 environments OptQuest development 274 erasing CB data 69 70 error handling 278 errors 182 184 event handling 279 event macros 279 event signatures 281 events 280 AfterIterationEvent 282 AfterOptimizationEvent 282 AfterSimulationEvent 282 BeforeIterationEvent 281 BeforeOptimizationEvent 281 BeforeSimulationEvent 282 EfficientFrontierEvent 283 example workbook 263 Excel add in creating 26 Excel charts creating 86 extracting CB data 123 extracting CB data 122 F filtering forecasts getting preferences 164 setting preferences 221 fitting distributions 131 160 170 181 219 forecast windows format preferences 135 opening CB 187 preferences 63 64 forecasts closing CB 72 defining CB 112 113 enumerating CB 121 filtering 221 A B C D E F G getting certainties 151 getting percentiles in CB 166 getting statistics for CB 167 retrieving CB information 162 selecting CB 209 setting CB attributes 219 trial data
118. Re bus grade 207 AS Tome ausu nac npe MM 208 CB SelectChart ot dE Rs exis Ex dus ae as ones ie ds bs det sx 208 dishes Nos REDE CB SelectChart Related Calls rr AA AA 9 4 ders eT d 208 A qu duds 209 CB SelectDecVar Example gees sey haves beg EA sa 209 IN RON LU da AAA AAA 209 A A b EE C QURE Ko Dace AMEN Do A do RC 209 CB SelectFore Example ids M or 3 209 CD Poe Rapid Cugat ale ode as eere e DU LBOURERDS Ge ekg ater dies deed ub ERE Need teary ecude seas 210 CB SensPrefs Example dara airada ones 210 CB SensPrefs Related Call ed fore res ts TTE UTEM 210 CB SensPrelsiND oss sess s PEI EN ee TAE ee NE 210 CE SEnSPRERND Example 122g cap ark p REC RR ar dee Re pp SCA 212 CB SensPrefsND Related Call Eds TOT EE Ros TP EE ss 213 E S E A E COI Pe spa er A A AAN AAA AAA A 214 a A ionia paa A 214 CB Sete BAuIbSLloai 4 urea o Eo ORK DEC E OC D ACER E ERA d 214 CB SetCBAutoLoad Example Se os ads s 219 CBoecBotelead Belated Call a uuu 5094440400849 rr AO COSA Workbook ii eere qe AA ARAS 215 CB SetCBWorkbookPriority Example ver erws lt 215 BER E A E E E EE N ERA RENEW zes b CAU at PIE RA AAA AAA ses de CB SetDecVar ExupleZ A AE AAA ob b ok do 217 CB SetDecVar Related Calls 218 CB SeiErccl007Foreeromd Mode A A RE XT XAR
119. Setting up specialized simulation environments The Developer Kit provides a link between Crystal Ball and your application It consists of a library of macro calls subroutines and functions that control many aspects of Crystal Ball Each copy of Crystal Ball comes enabled to use the Developer Kit so that programs you develop today can be run by other users as well This kit is the key that unlocks the programmability of Crystal Ball and guides you through the many calls available In addition to the descriptions of the calls or subroutines and functions this manual contains examples that illustrate usage of the Developer Kit in several practical applications You are encouraged to study these examples before starting out on your own applications Should you need additional help technical support is available with appropriate licenses If you have Oracle Crystal Ball Decision Optimizer Fusion Edition Appendix A Using the OptQuest Developer Kit describes how to automate OptQuest optimizations About the Oracle Crystal Ball Developer Kit 19 See Appendix B Using the Predictor Developer Kit for information about automating and controlling Predictor forecasting Note The Predictor Developer Kit described in this Developer s Guide is completely rewritten Code written for CB Predictor in Crystal Ball versions earlier than 11 1 1 3 00 is not compatible with the current version of Predictor or this Predictor Developer Kit Who Shou
120. SimTrials cbTwoDInnerSimTrials to specify the number of trials in the inner variability simulation For Index 5 cbTwoDShowDefineFore 1 Uses display settings for each cbTwoDForeOption Integer forecast chart the equivalent of the Show Forecasts As Defined dialog setting For Index 5 cbTwoDShowTargetFore 2 Shows only the target forecast cbTwoDForeOption Integer the equivalent of the Show Only Target Forecast dialog settin For Index 5 cbTwo cbTwoDHideFore 3 Hides all forecasts the ForeOption Integer equivalent of the Hide All Forecasts dialog setting For Index 6 cbTwoDShowForeStat 1 Used with cbTwoDOutputOption cbTwoDOutputOption Integer and a boolean Value parameter to specify whether to include forecast statistics in the output report if followed by True includes statistics in the report For Index 6 cbTwoDShowPercentiles 2 Used with cbTwoDOutputOption cbTwoDOutputOption Integer and a boolean value parameter to specify whether to include percentiles in the output report if followed by True includes percentiles in the report For Index 6 cbTwoDShowCapMetrics 3 Used with cbTwoDOutputOption cbTwoDOutputOption Integer and a boolean Value parameter to specify whether to include capability metrics in the output report if followed by True includes capability metrics in the report For Index 7 cbTwoDPercentTenNinety 1 Specifies the 10th and 90th cbTwoDPercent Integer percentiles For Index 7 cbTwoDPer
121. StdDev 5 Returns the standard deviation cbFstVariance 6 Returns the variance cbFstSkewness 7 Returns the skewness cbFstKurtosis 8 Returns the kurtosis cbFstCV 9 Returns the coefficient of variability cbFstRangeMin 10 Returns the range minimum cbFstRangeMax 11 Returns the range maximum cbFstRangeWidth 12 Returns the range width cbFstStdError 13 Returns the standard error cbFstBaseCase 14 Returns the base case initial value of the forecast cell cbFstCp 50 Returns the Cp for short term data or Pp for long term data cbFstCpklower 51 Returns the Cpk lower for short term data or Ppk lower for long term data cbFstCpkupper 52 Returns the Cpk upper for short term data or Ppk upper for long term data cbFstCpk 53 Returns the Cpk for short term data or Ppk for long term data cbFstCpm 54 Returns the Cpm for short term data or Ppm for long term data cbFstZLSL 55 Returns the Z LSL cbFstZUSL 56 Returns the Z USL cbFstZst 57 Returns the Z st 168 Crystal Ball Macro Calls Named Constant Value Index Value Description cbFstZlt 58 Returns the Z It cbFstpNCbelow 59 Returns the p N C below LSL cbFstpNCabove 60 Returns the p N C above USL cbFstpNCtotal 61 Returns the p N C total cbFstPPMbelow 62 Returns the PPM below LSL cbFstPPMabove 63 Returns the PPM above USL cbFstPPMtotal 64 Returns the PPM total Note To use CB GetForeStat in a worksheet use the integer value of the Index parameter
122. Support and More Oracle offers a variety of resources to help you use Crystal Ball such as technical support training and other services For information see http ww oracle com crystalball Documentation Changes 21 22 Welcome Crystal Ball Developer Kit Overview In This Chapter MAI Cr erc 23 Hew to Use the Crystal Ball Developer Mb A e o Rua estin A UR oes 24 Alphabetic Liston Crystal Ball Macro Galle usina A A A pede 27 Functions For Use in Excel Models ra e A d d ceci A A d eR Un inn 32 Opening and Coane GERE Ball auus quauis paa a A aa a dde 32 Seting Up ana Running IMA a E E E 33 Canton Cristal Ball COSES e 34 A O asa IM SD 325 Ea O A A A EE Ed UE ORUM SANE AUT 39 Sethe and Getting Preference ri A A PA AA EA A A 36 Cita NIU e A 37 RO 37 Introduction This chapter tells how to use the Crystal Ball Developer Kit and provides lists of macro calls subroutines and functions from different categories with references to Chapter 3 for detailed definitions and examples The chapter begins with instructions for using the Crystal Ball Developer Kit followed by an alphabetical list of the Crystal Ball calls including a brief summary of the actions they perform This section serves as an index to the Crystal Ball calls in Chapter 3 The following sections list groups of macro calls used for various purposes
123. TableND Related Calls Name CB DecisionTable Description Launches the Decision Table tool CB GetDecisionTableOption Returns current settings for the Decision Table tool CB DefineAltParms This function creates or changes an alternate parameter set for continuous distributions listed in Table 53 The function returns a value used by CB DefineAssumND 10 Note Ifyou use CB DefineAltParms to define an alternate parameter set using only percentiles you will not be able to retrieve parameter values with CB GetAssum Table 49 CB DefineAltParms Returned Data Type Returned Value An encoded integer that indicates the distribution and parameter set that CB DefineAssumND should use Returned Data Type Integer Note A return value of 1 indicates an improperly defined alternate parameter set Table 50 CB DefineAltParms Parameters Parameter DistType VBA Data Type Integer Value Integer value or named constant See Table 53 Description Specifies a distribution type for the assumption The number of parameters varies with the distribution type See Table 53 for types and associated parameters CB DefineAltParms 99 Parameter VBA Data Type Value Description Parml Parm2 Parm3 All are Double Double value or named Specifies the alternate required constant See Table 51 parameters used to define the following distribution You must supply three param
124. The default for any preference is the previous setting in the Cell Preferences dialog Caution CB CellPrefsND cannot run if a cell with Crystal Ball data is located in a write protected worksheet Table 19 CB CellPrefsND Parameters Parameter VBA Data Type Description Index1 Integer Changes assumption forecast or decision variable cells depending on the selected constant or index value e cbCelAssum 1 e cbCelFore 2 e cbCelDecVar 3 Index2 Integer Sets preferences depending on the Value parameter that follows it For constant and index values see Table 20 Value Variant Works with Index2 to specify preference settings as described in Table 21 DoNotApply Optional boolean True applies changes only to new Crystal Ball cells False applies changes to existing and new Crystal Ball cells The default is False Level Optional Integer Specifies whether changes are applied globally to all open and new workbooks to cells of that type in the active workbook or to cells of that type in the active worksheet depending on the selected constant or index value e cbCelGlobal 0 e cbCelWorkbook 1 e cbCelWorksheet 2 The zndex2 parameter listed in the following table Table 20 works with the va1ue parameter to set cell preferences For Value parameter values see Table 21 CB CellPrefsND 61 Table 20 CB CellPrefsND Index2 Parameter Values Integer Required Constant Value cb
125. Type Value Description e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter CB GetLockFitParm Example The following macro statements define two variables named LockVal and useLock lock the Location parameter of the Weibull distribution and set it to the value of 250 unlock the same parameter for the gamma distribution while setting the value of that parameter to 200 test whether the Weibull and gamma distributions have parameter locking switched on and finally return the current values set for the Location parameters of the Weibull and gamma distributions Dim LockVal as Double Dim UseLock as boolean Set the Weibull Location parameter to 250 for locking purposes and lock ut cb LockFitParm cbDfaWeibull True 1 250 Set the gamma Location parameter to 200 for locking purposes but do not lock it cb LockFitParm cbDfaGamma False 1 200 Test if the Weibull distribution has parameter locking switched on returns True UseLock CB GetLockFitParm cbDfaWeibull Test if the gamma distribution has parameter locking switched on returns False UseLock CB GetLockFitParm cbDfaGamma Find the value set for the Weibull Location parameter returns 250 jOckVal CB GetLockFitParm cbDfaWeibull 1 Find the value set for the gamma Location parameter returns 200 OCKkVal CB GetLockFitParm
126. You can also create and use these objects outside of that namespace with the following Crystal Ball Developer Kit calls e CB OptSetup e CB OptRuntime To do this you must reference CBDevKit as well as CBCOMDewvKit Then you can use Visual Basic or VBA syntax to apply methods and properties For example CB OptSetup Show can be used in Visual Basic or VBA code to display the OptQuest wizard User defined Event Macros for Optimizations This section summarizes information about user defined Excel VBA event macros that can run at various times while an OptQuest optimization runs User defined Event Macro Names Users can create Excel VBA event macros for workbooks Depending on the event selected Crystal Ball runs them automatically at various points in a simulation or optimization The original simulation specific macros are described in Chapter 4 of the Crystal Ball User Manual Beginning with Crystal Ball 11 1 1 0 00 macros based on VBA events are now available to run at various points during an OptQuest optimization Table 191 following summarizes events that can be defined with VBA code and describes when they run Note Event macros must be attached to worksheets or workbooks and not modules Table 191 Events Accessible through VBA and When They Run within an Optimization Event Type Runs BeforeOptimizationEvent Optimization At the start of an optimization when the OptQuest Run command is given or an equivalent com
127. a subroutine or function macro CB AlertOnMacroResultError 43 Table 5 CB AlertOnObsolete Parameter Parameter turnon VBA Data Type Description boolean True displays an alert message when an obsolete call or constant attempts to run False switches off this alert The default is True CB AlertOnObsolete Example This example switches off alerts when obsolete macro calls arguments and functions are used CB AlertOnObsolete False CB AlertOnObsolete Related Calls Name CB AlertOnArgumentError Description Displays a message when an argument error occurs CB AlertOnMacroResultError Displays a message when an execution error occurs CB AssumPrefsND This subroutine sets attributes of Crystal Ball assumptions without using the Preferences menu on the Define Assumption dialog The default for any preference is the previous setting in the interface Different from Crystal Ball 2000 5 5 5 this subroutine is used to change preferences for individual assumptions instead of all assumptions You must select a single cell with an assumption before using this subroutine If the selected cell does not contain an assumption a cbErrNoAssumptionInCell error appears Table 6 CB AssumPrefsND Parameters Named Constant or Parameter VBA Data Type boolean Value Index Value Description PrefItem Integer cbAssumShowCDF 1 Sets whether to display the distribution as a PDF False or CDF True
128. a 25th percentile value of 5 a likeliest value of 10 and a 75th percentile value of 15 Note Ifyou use the numeric value of the index instead of the constant name for cbParmPercentile as in Example 3 you must use the sample syntax 0 percentile so that the function can identify the parameter by the numeric value Range B7 Select Valuel CB DefineAltParms cbDfaTriangular 0 25 10 0 75 CB DefineAssumND Valuel 5 10 15 CB DefineAltParms Related Calls Name Description CB DefineAssumND Defines or changes the assumption in the selected cell CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Changes certain attributes for the assumption in a cell CB DefineAssum This subroutine opens either the Distribution Gallery to define new assumptions or the existing distribution dialogs to change existing assumptions in the selected cell The selected cell must be a blank cell or a simple value cell You cannot define an assumption in a cell with a formula a cell reference or text 102 Crystal Ball Macro Calls If a simulation runs before this subroutine is used the simulation must be reset before the assumption is defined Note Before calling this subroutine reset the simulation and select a cell CB DefineAssum Example 1 This example selects cell B5 a single value cell with no defined assumption and then opens the Distribution Gallery so you can select a distributio
129. a Related Calls Name CB CheckDataND Description Checks Crystal Ball data cells for validity initializes variables without error prompting CB EnumAssum Enumerates assumption cells for all open workbooks CB EnumFore Enumerates forecast cells for all open workbooks CB EnumDecVar Enumerates decision variable cells for all open workbooks CB CheckDataND Like CB CheckData this subroutine scans Crystal Ball data on open worksheets checks the assumptions for validity and initializes internal variables for the start of an enumeration However if an error occurs no dialogs appear Instead an error is returned by CB MacroResultDetail CB MacroResultDetail on page 184 68 Call CB CheckDataND or CB CheckData each time you start a new enumeration use a CB Get call that relies on cell references that might have changed and each time you delete or add data Use CB CheckDataND or CB CheckData before using calls that extract data or create reports CB CheckDataND Example This example runs a simulation of 500 trials initializes all the internal variables for the following enumeration and then enumerates all the forecasts opening each forecast chart Dim r As Range Dim s As String CB Simulation 500 CB CheckDataND s CB EnumFore While s lt gt Set r Range s CB OpenFore s CB EnumFore t t l Wend Crystal Ball Macro Calls CB CheckDataND Related Calls
130. all is loaded within Excel CB CBLoaded 59 Note CB CBLoaded must return True before any Crystal Ball features can be used Table 18 CB CBLoaded Returned Data Type Returned Value Returned Data Type Whether Crystal Ball is loaded within Excel boolean CB CBLoaded Example To retrieve the current setting of CB CBLoaded use this call in a function as follows ReturnValue CB CBLoaded CB CBLoaded Related Calls Name Description CB GetCBAutoLoad Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Excel opens CB SetCBAutoLoad Sets or cancels autoloading with Excel determines whether Crystal Ball is set to open whenever Excel opens CB Shutdown Closes Crystal Ball while leaving Excel open CB Startup Loads Crystal Ball into Excel if possible and indicates when Crystal Ball has been successfully opened CB CellPrefs 60 This subroutine opens the Cell Preferences dialog so that you can set cell preferences for existing Crystal Ball data cells or new cells CB CellPrefs Example This example opens the Cell Preferences dialog so you can set and apply new cell preferences CB CellPrefs CB CellPrefs Related Calls Name Description CB CellPrefsND Sets attributes of Crystal Ball cells Crystal Ball Macro Calls CB CellPrefsND This subroutine sets attributes of Crystal Ball cells without the Cell Preferences dialog
131. all uses this password to unlock the worksheet while running and lock it again afterwards The following commands will work after CB WorksheetProtection is called e CB Simulation e CB SingleStep e CB Reset e CB ResetND e Excel Save or SaveAs Note Other calls that define or modify Crystal Ball data such as CB DefineAssum and CB SetAssum also require unprotected worksheets before they will run However these calls are not affected by CB WorksheetProtection Worksheets must be manually unprotected before data modifying calls not listed above will work Once the CB WorksheetProtection command has run on each protected worksheet and the workbook saved nothing else needs to be done for these commands to work Call CB WorksheetProtection with the sheet you want to protect active It only needs to be called through VBA for example from within the VBA Editor one time for each sheet Once the code has been run and the workbook saved the code can be deleted and Crystal Ball will remember the password for future simulations It does not matter if the sheet is already protected when CB WorksheetProtection is called as long as the password passed into the first parameter is consistent with the current worksheet password The password is encrypted so users cannot read it Table 190 CB WorksheetProtection Parameters Parameter VBA Data Type Value Description aPassword String Any alphanumeric string Specifies the user assigned passw
132. alue2 Optional Variant Any positive whole number For Index 4 cbRunSameRandoms Long Sets the initial seed value for the random number generator The following Index named constant and index values Table 148 work with the va1ue1 and Value2 parameters to set Crystal Ball run preferences Table 148 CB RunPrefsND Index Parameter Values Required Integer Named Constant Value Index Value Description cbRunMaxTrials 1 Sets the maximum number of trials to the number in Value1 cbRunStopOnError 2 Sets whether the simulation stops on calculation errors in forecast cells according to Valuel cbRunSameRandoms 4 Sets whether the random number generator uses the same sequence of CB RunPrefsND 195 Named Constant Value Index Value Description random numbers Va1ue1 and sets the initial seed value Value2 cbRunSamplingMethod Selects whether to use the Latin Hypercube or Monte Carlo sampling method according to Valuel cbRunSampleSize Sets the Latin Hypercube sampling method s sample size to Valuel cbRunCorrelationsOff 10 Sets whether to turn off correlations according to Valuel cbRunMinimizeHost 26 Sets whether to minimize Excel during simulations according to Valuel Note This constant only applies in Normal and Demo speeds it does not apply in Extreme speed cbRunMinimizeSheets 27 Sets whether to minimize worksheets during simulat
133. ame of the next chart of the specified type CB SelectDecVar This subroutine selects all decision variables in the current worksheet The desired worksheet must be active for Crystal Ball to run this command Note Before calling this subroutine activate the worksheet where you want to select Crystal Ball data CB SelectDecVar Example This example activates the Model worksheet of the Futura with OptQuest xls workbook and selects all decision variables in the worksheet Workbooks Futura with OptQuest xls Worksheets Model Activate CB SelectDecVar CB SelectDecVar Related Calls Name Description CB SelectAssum Selects all assumptions in the current worksheet CB SelectFore Selects all forecasts in the current worksheet CB SelectFore This subroutine selects all forecasts in the current worksheet Before calling this subroutine activate the worksheet where you want to selectCrystal Ball data CB SelectFore Example This example activates the Model worksheet of the Futura with OptQuest xls workbook and selects all the forecasts on the worksheet Workbooks Futura with OptQuest xls Worksheets Model Activate CB SelectFore CB SelectDecVar 209 CB SelectFore Related Calls Name Description CB SelectAssum Selects all assumptions in the current worksheet CB SelectDecVar Selects all decision variables in the current worksheet CB SensPrefs Opens the Sensitivity Prefe
134. an setting of the TurnOn parameter True if CB AutoDownshift is set to automatically downshift to Normal speed or False if it is not set to downshift CB CellPrefsND e Index2 parameter new constants added o cbCelDistMedian 5 o cbCelRangeMin 6 e Value parameter constant cbCelPattern 1 has 0 17 values instead of 0 3 additional values are added for the new Index2 constants with indices 5 7 Changes to Existing Calls 249 e Level parameter optional added to support the new Apply To dialog control with new constants o cbCelGlobal 0 o cbCelWorkbook 1 o cbCelWorksheet 2 CB ChartPrefsND e Index parameter constant removed obsolete cbChtRedrawFrequency 4 CB CheckData e Should now be called each time data is deleted or added as well as each time a new enumeration is started CB ClearData e Ifthe selected range contains more than one type of data a dialog appears and prompts for the type of data to clear e Simulations must now be reset before CB ClearData is called CB ClearDataND e Simulations must now be reset before CB ClearDataND is called CB CloseFore e Can now be called while a simulation is running CB CloseSensitiv e Achartcan now be explicitly selected via CB EnumChart and CB SelectChart before it can be closed CB CloseTrend e Achart can now be explicitly selected via CB EnumChart and CB SelectChart before it can be closed 250 Changes from Previous V
135. and Licensing Guide 286 Using the Predictor Developer Kit Microsoft NET Framework Version The Predictor Developer Kit has been tested to run properly with Microsoft NET Framework Versions 2 0 3 0 and 3 5 You can force the Predictor Developer Kit to run against a specific version of the NET Framework using an application configuration file in the form of lt appname gt exe config placed in the folder of the application s executable The following section forces the Predictor Developer Kit code to run against Microsoft NET Framework 2 0 lt configuration gt lt startup gt lt supportedRuntime version v2 0 50727 gt lt startup gt lt configuration gt You might also want to run against a specific version of Microsoft Excel In that case appname would be excel and you would be modifying a file called excel exe config 64 bit Operating System Execution Currently Predictor Developer Kit applications must execute as 32 bit applications when running on 64 bit capable operating systems such as Windows XP Window Server 2003 or Windows Vista 64 bit To prevent runtime errors in this environment configure your build properties to set the target platform to x86 Predictor Developer Kit Namespace The Predictor Developer Kit contains the following main namespace Decisioneering CB CBCOMDevKit This namespace contains the classes required to set up and run time series forecasts with the Predictor Developer Kit No
136. and cbParmLogStDev 252 Changes from Previous Versions e cbParmMode 15 is included to support the Extreme Value distribution for backward compatibility with Crystal Ball 2000 x 5 x In later versions of Crystal Ball that distribution is replaced with the Maximum Extreme and Minimum Extreme distributions cbParmMode is deprecated in this version of Crystal Ball and are obsolete in a future version e Theimplementation of DefineAltParms in Crystal Ball 7 x and later versions including 11 x is different from Crystal Ball 2000 5 5 5 in that a different integer is returned for each call even if the parameters are the same This number is simply a pointer to the alternate parameter set Code written in Crystal Ball 2000 5 5 5 should run the same in Crystal Ball 7 2 or later including 11 x CB DefineAssum e Ifa simulation was run earlier it must be reset before this call runs CB DefineAssumND e Ifasimulation was run earlier it must be reset before this call runs e The optional Dynamic parameter is deprecated in this release since all cell references are now dynamic It should not be used in new code e Anoptional fourth parameter Parm4 is added to support the DistType constant cbDfaBeta which now has four parameters e The following new constants are provided for DistType to support new distributions added in versions of Crystal Ball beginning with Crystal Ball 7 0 o cbDfaHypergeometricSuccess 17 o cbDfaMinExtreme
137. ange to the assumption s cell location Even if set LowCutoff and HighCutoff are ignored for custom distributions Parmi can only be set to cumulative True if the table of data points has two three or four columns CB DefineAssumND 107 Call CB MacroResult afterwards to determine whether the command was successful For more information about defining custom distributions using a data range see the Oracle Crystal Ball User s Guide CB DefineAssumND Custom Distribution Example This example selects cell B3 and the range D17 to G22 CB DefineAssumND interprets the data located in this second range of cells using the format described in the discussion of custom distributions in the Oracle Crystal Ball User s Guide Union Range B3 Range D17 G22 Select CB DefineAssumND cbDfaCustom False Sales CB DefineAssumND Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB DefineAssum Defines or changes assumptions in selected cells using a dialog CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Changes certain attributes for the assumption in a cell CB DefineDecVar This subroutine opens the Define Decision Variable dialog to create a new decision variable or change an existing decision variable in the selected cell The selected cell must be blank or a simple value cell You cannot define a decision
138. any previous settings made with Choose commands such as cbRptChooseScatter 31 The cbRptOptimizer constants 39 43 were added in Crystal Ball 11 1 1 0 00 With Index set to cbRptForePercentiles you can specify which percentile ranges to include in the report see Table 32 Table 32 For Index cbRptForePercentiles Value2 Values Optional Integer Named Constant Value Index Value Percentile Ranges cbPctQuartiles 1 Quartiles 25 cbPctQuintiles 2 Quintiles 2096 cbPctDeciles 3 Deciles 1096 This is the default cbPctlcosatiles 4 Icosatiles 596 cbPctSet1 5 2 5 5 50 95 97 5 iles cbPctSet2 6 10 25 50 75 90 iles cbPctSet3 7 5 95 percentiles cbPctSet4 8 10 90 percentiles CB CreateRptND 85 With Index set to coRptChooseFore you can specify which forecasts to include in the report see Table 33 Table 33 For Index cbRptChooseFore Value1 Values Optional Integer Named Constant Value Index Value Description cbChfAll 1 Includes all forecasts cbChfOpen 2 Includes open forecasts cbChfChosen 3 Includes chosen forecasts Run this option after adding forecasts cbChfAdd 4 Adds the forecast in the selected cell to the list of chosen forecasts cbChfClearList 5 Clears the list of chosen forecasts With Index set to cbRptChooseAssum you can specify which assumptions to include in the report see Table 34 Table 34 For Index c
139. arameter to set forecast chart Axis preferences 136 Crystal Ball Macro Calls Table 80 CB FormatPrefsND Value Parameter Values Required Variant Used With Specified Named Constant or Values of Index boolean Value Index Value Description For Index 1 cbFttFixed 1 Sets the axis labels to have cbFmtFormatType Integer a fixed decimal place format For Index 1 cbFttGeneral 2 Sets the axis labels to be a cbFmtFormatType Integer general Excel number format For Index 1 cbFttScientific 3 Sets the axis labels to cbFmtFormatType Integer appear in scientific notation For Index 2 True or False n a True uses the underlying cbFmtUnderlying Boolean cell format overriding any other formatting previously set False uses General formatting For Index 3 True or False n a True uses commas or cbFmtCommas Boolean another thousands separator character in the axis labels False does not For Index 4 Any whole number up to n a Sets the number of fixed cbFmtDecimalPlace 232 decimal places This works Integer only if you set the format type to cbFttFixed or cbFttScientific CB FormatPrefsND Example 1 This example selects a forecast cell turns off the underlying cell format preference in case it is on and then changes the format of the axis labels to be a fixed number of decimal places 3 Range B7 Select cb FormatPrefsND cbFmtUnderlying False cb FormatPrefsND cbFmtFormatType cbFttFix
140. arameters Parameter Index VBA Data Type Integer Value See Table 82 for Index values Description Defines which assumptions decision variables or forecasts should be frozen hold to their worksheet values during a simulation Values listed in Table 82 are 1 cbFrzAddCell 2 cbFrzClearlist 3 cbFrzSetList Frozen Optional Integer True or False Sets whether the cells in the list created by the Index parameter are frozen during simulations True or enabled while all unlisted cells are frozen False The default is True The following table shows named constant and index values for the Index parameter Table 82 CB FreezeND Index Parameter Values Required Integer Named Constant Value Index Value Description cbFrzAddCell 1 Adds the selected cell to the list of frozen or enabled cells cbFrzClearlist 2 Clears the list of frozen or enabled cells added with cbFrzAddCell cbFrzSetList 3 Depending on the value of the Frozen parameter indicates that the listed cells are frozen True or the reverse enabled False The default CB FreezeND 139 Named Constant Value Index Value Description is False This constant must be called after cbFrzAddCell to activate the freeze See CB FreezeND Example below CB FreezeND Example This example resets the model adds cells B6 and B7 to the list of frozen enabled cells clears those cells from
141. as entering an external assumption function such as CB Normal into a worksheet cell External assumptions are actual functions that return values using normal Excel syntax but you cannot correlate them with other assumptions nor do they appear in any reports or sensitivity analyses Calling this function CB DefineAssumND is equivalent to selecting Define then Define Assumption CB DefineAssumND Example 1 This example defines a uniformly distributed assumption with a minimum value of 30 a maximum value of 40 and names it Number Of Units This example assumes you have already selected a single cell CB DefineAssumND cbDfaUniform 30 40 Number of Units CB DefineAssumND Example 2 This example defines a normally distributed assumption with the following characteristics and places it in the currently selected cell e A mean of 15 000 e A standard deviation of 1000 e The third parameter left blank since the normal distribution only uses 2 parameters e A lower truncation point defined by the value in cell B50 e An upper truncation point of 16 100 e A title of Expenses CB DefineAssumND cbDfaNormal 15000 1000 B50 16100 Expenses Defining Custom Distributions To define a custom distribution your macro code must first set the cell selection to point to both the assumption cell and a table containing the custom data points You can do this using the Union object with the Range object to append the table s cell r
142. ast line of code runs the Batch Fit tool CB ResetND Select all distributions CB BatchFitND cbBftSelectDistAll Set input range orientation data in columns CB BatchFitND cbBftInputOrientation cbBftInputColumns Input range has headers CB BatchFitND cbBftInputHeader True Select input range CB BatchFitND cbBftInputRange A1 C500 Select the Anderson Darling ranking method CB BatchFitND cbBftRankMethod cbFitAndersonDarling Crystal Ball Macro Calls Select output location starting in cell D1 of a new worksheet CB BatchFitND cbBftOutputLocation cbBftNewWorksheet D1 Show correlation matrix between the data series CB BatchFitND cbBftOutputCorrelationMatrix True Do not format output CB BatchFitND cbBftOutputFormat False Correlate assumptions where the absolute correlation is 0 2 or greater CB BatchFitND cbBftOutputCorrelation True 0 2 Create goodness of fit report named Fit Statistics CB BatchFitND cbBftOutputGoodnessOfFitReport True Fit Statistics Create assumption report Fit Assumption Report with full statistics CB BatchFitND cbBftOutputAssumReport True Fit Assumption Report CB BatchFitND cbBftOutputAssumFullStatistics True Run the tool CB BatchFitND cbBftRun CB BatchFitND Example 2 This example runs the Batch Fit tool using default preferences or settings from a previous run in the current Excel session CB ResetND
143. ate Report dialog that enables you to select report options and create a report Use CB CheckData before using this call CB CreateRpt Example This example opens the Create Report dialog so you can include assumptions decision variables forecasts and charts CB Simulation 1000 CB CheckData CB CreateRpt CB CreateRpt Related Calls Name Description CB CreateRptND Sets report preferences and creates a report from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractData Extracts data from the current simulation and restored results optimization or time series forecast using a dialog CB ExtractDataND Extracts data from the current simulation and restored results optimization or time series forecast without a dialog CB CreateRptND 80 This subroutine sets report preferences and creates a Crystal Ball report For any preferences not manually set the default is the current setting in the Create Report dialog Use CB CheckData before using this call Note Although Full is the default report type in the Create Report dialog Custom cbRptCustom is the default report for CB CreateRptND To create a custom report call CB CreateRptND as follows before creating the report CB CreateRptND cbRptDefinedType cbRptCustom Table 30 CB CreateRptND Parameters Parameter VBA Data Type Description Index Integer Specifies which report preference you
144. ating decision 120 retrieving decision information 158 VB 25 VBA 24 versions Crystal Ball 176 versions data 178 Visual Basic VB script 25 G H Visual Basic for Applications VBA scripts 24 W welcome to the Developer Kit 19 what you will need 20 270 who this program is for 20 269 286 windows 34 opening CB forecast 187 write protection 26 MN 0 P RS T U VW Index 299 A B C D E F G H L M N OP R S TU V W 300 Index
145. ation and technical data delivered to U S Government customers are commercial computer software or commercial technical data pursuant to the applicable Federal Acquisition Regulation and agency specific supplemental regulations As such use duplication disclosure modification and adaptation of the Programs including documentation and technical data shall be subject to the licensing restrictions set forth in the applicable Oracle license agreement and to the extent applicable the additional rights set forth in FAR 52 227 19 Commercial Computer Software Restricted Rights June 1987 Oracle USA Inc 500 Oracle Parkway Redwood City CA 94065 The Programs are not intended for use in any nuclear aviation mass transit medical or other inherently dangerous applications It shall be the licensee s responsibility to take all appropriate fail safe backup redundancy and other measures to ensure the safe use of such applications if the Programs are used for such purposes and we disclaim liability for any damages caused by such use of the Programs Oracle JD Edwards PeopleSoft and Siebel are registered trademarks of Oracle Corporation and or its affiliates Other names may be trademarks of their respective owners The Programs may provide links to Web sites and access to content products and services from third parties Oracle is not responsible for the availability of or any content provided on third party Web sites You bear all ris
146. ations True or to let them open as set in each forecast False Suppressing forecast windows can help speed up long simulations MinimizeHost Optional Variant True or False Sets whether to minimize Excel during simulations True or not False Minimizing Excel can help Speed up long simulations This parameter only works in Normal or Demo speed not Extreme speed MinimizeAllSheets Optional Variant True or False Sets whether to minimize worksheets during simulations True or not False Minimizing worksheets can help speed up long simulations This parameter only works in Normal or Demo speed not Extreme speed StatusString Optional Variant Words surrounded by quotes Inserts a string into the status bar during the simulation If this is CB Simulation 227 Parameter VBA Data Type Value Description omitted no special string appears ShowControlPanel boolean True or False Sets whether to show the Optional Crystal Ball Control Panel during simulations True or not False Hiding it can help speed up long simulations The default is False for simulations run through the Crystal Ball Developer Kit This parameter is new for Crystal Ball versions later than 5 5 CB Simulation Example 1 This example resets any previously run simulation and runs a simulation of 1000 trials CB ResetND Above call makes sure the trials begin at 1
147. bRptChooseAssum Value1 Values Optional Integer Named Constant Value Index Value Description cbChaaAll 1 Includes all assumptions cbChaChosen 2 Includes chosen assumptions Run this option after adding assumptions cbChaAdd 3 Adds the assumption in the selected cell to the chosen assumptions Use cbChaChosen after this option cbChaClearList 4 Clears the list of chosen assumptions cbChaOpen 5 Includes all open assumptions With Index set to cbRptChartType you can specify what type of chart the report uses see Table 35 Table 35 For Index cbRptChartType Value1 Values Optional Integer Named Constant Value Index Value Description cbChtColored 1 Makes all charts colored Crystal Ball format cbChtExcel 2 Makes all charts Excel format Note cbChtBW 0 was removed as an index to this parameter With Index set to cbRptSummary you can specify what to include in the summary see Table 36 86 Crystal Ball Macro Calls Table 36 For Index cbRptSummary Value2 Values Optional Integer Named Constant Value Index Value Description cbRptSummaryTitle 1 Includes the report title cbRptSummaryDate 2 Includes the date cbRptRunPreferences 3 Includes run preferences for the simulation cbRptRunStatistics 4 Includes run statistics for the simulation With Index set to coRptChooseDecVar you can specify which decision variables to include in a report see Table 3
148. bilities more accurately cbDatStatistics Extracts statistics cbDatPercentiles Extracts percentiles cbDatFrequencies Extracts the number of data points in each chart bin cbDatSensitiv Extracts sensitivity data cbDatCapMetrics Extracts capability metrics data True extracts the metrics and False does not extract the metrics cbPctSet3 Extraction of the 5 and 95 percentiles Note The constant coDatCumulative 5 is not included in this release The following values are used with Index cbExtChooseFore to specify forecast data for extraction Table 68 Value Parameter Values that Support Index Constant cbExtChooseFore Named Constant Value cbChfAll Index Value Description Includes all forecasts CB ExtractDataND 127 Named Constant Value cbChfOpen Index Value Description Includes open forecasts cbChfChosen Includes chosen forecasts Use after cbChfAdd cbChfAdd Adds the forecast in the selected cell to the list of chosen forecasts Use cbChfChosen after this option Note An erroris returned if the user attempts to add cbChfAdd a forecast which contains no underlying data During extraction only those forecasts with underlying data are actually extracted The others are ignored cbChfClearList Clears the list of chosen forecasts The following values are used with Index cbExtPercentiles to specify per
149. bility and is replaced by cbDfaMinExtreme and cbi DfaMaxl Extreme in later versions of Crystal Ball Beginning with version 11 1 1 0 00 the lognormal distribution CB GetFitParm 161 has three parameters instead of two If this call is used in a model that was created in an earlier version of Crystal Ball the third parameter has a value of 0 CB GetFitParm Example This example selects a range of data in column D and then calls CB Fit to fit a triangular distribution to the range of data printing the results of each possible test to the worksheet next to the original data in cells E4 to E7 After the fit it uses CB GetFitParm to put the Minimum Likeliest and Maximum parameters in cells E8 E9 and E10 CB SetFitRange Range D4 D104 For i 1to4 Range E3 Offset i Value CB Fit cbDfaTriangular i Next i For j 1 to 3 Range E7 Next j Offset j Value CB GetFitParm j CB GetFitParm Related Calls Name CB DefineAssum Description Defines an assumption in the selected cell using a dialog CB DefineAssumND Defines an assumption in the selected cell without using a dialog CB Fit Fits a specific probability distribution to a selected set of data range of cells CB GetLockFitParm Returns whether a distribution and optionally specific parameters have locked values for fitting purposes CB LockFitParm Sets parameter locking for distributions and
150. ble 27 CB CorrelateND Parameters Parameter VBA Data Type Value Description Coefficient Variant A number between 1 0 Sets the correlation and 1 0 coefficient between two selected assumptions SecondAsm Optional Excel Range A single cell outside of the Sets a single assumption specified range on the same or another worksheet cell as the second cell to correlate with the first specified cell in a selected range The second cell specified with SecondAsm should not be part of the selected range and can be on another worksheet in the same workbook To specify two assumption cells to correlate either e Selecta rectangular cell range so that the two assumptions define opposite corners or endpoints of a column or row or CB CorrelateND 77 78 e Select a single assumption cell and use the optional SecondAsm parameter to define a second assumption cell on the same worksheet or another worksheet on the same workbook If the cells to correlate are in the bottom left and top right corners of the selected range activate one of the cells before calling this subroutine Ifthe two assumption cells are in the same column or row the selected cell range is one cell wide or tall If the cells are adjacent the selected region has exactly two cells in it Unless you are using the SecondAsm parameter both the selected cell and the opposite corner of the selected range must contain assumption cells If the selected region i
151. bleOption cbDecGetDecVar cbDecVar2 Gets the number of test values for the first and second decision variables Range M9 Value CB GetDecisionTableOption cbDecSimOption _ cbDecNumValuesVar1 Range M10 Value CB GetDecisionTableOption cbDecSimOption _ cbDecNumValuesVar2 trials per simulation Range Mil Value CB GetDecisionTableOption cbDecSimOption _ cbDecSimTrials Returns the forecast chart window display setting Range Mi2 Value CB GetDecisionTableOption cbDecForeOption CB GetDecisionTableOption Related Calls Name CB DecisionTable Description Launches the Decision Table tool CB DecisionTableND Runs the Decision Table tool without displaying dialogs CB GetDecVar This function retrieves information for a specific decision variable cell Note For best results always call CB CheckData before calling this function to ensure the latest data values are used Table 109 CB GetDecVar Returned Data Type Returned Value Returned Data Type The specified decision variable data Variant 158 Crystal Ball Macro Calls Table 110 CB GetDecVar Parameters Parameter VBA Data Type Value Description DecVarReference Variant In a macro Range B3 Points to the desired decision variable cell Index Integer See Table 111 Returns specified data from the selected decision variable using the constant and index values shown in Table
152. boolean to Variant e The first parameter name is changed from DecVarRef to DecVarReference to correct a documentation error e The data type of the first parameter is changed from Range to Variant e There is a new Index constant cbDecFrozen 6 Changes to Existing Calls 259 e Starting with Crystal Ball 11 1 1 0 00 two new Index constants are added o cbDecType 4 with Value constants coDecVarTypeContinuous 0 cbDecVarTypeDiscrete 1 cbDecVarTypeBinary 2 cbDecVarTypeCategory 3 and cbDecVarTypeCustom 4 o cbDecCustomData 7 which supplies a data string for Value cbDecVarTypeCustom 4 CB SetFore e Data type returned changes from boolean to Variant e The first parameter name is changed from ForeRef to ForeReference to correct a documentation error e Index constant cbForWindowSize 3 is obsolete and is removed e Index constant cbForFilterGlobal 18 was obsolete in the Crystal Ball 7 1 version of the Developer Kit It is now valid and has been added back e Index constants cbForFrozen 19 cbForLSL 20 cbForUSL 21 and cbForTarget 22 are new e Value constants are removed or added accordingly CB SimResult e Was previously documented incorrectly in the Crystal Ball 2000 5 Developer Kit as CB SimResultND CB Simulation e Optional parameters HideForecasts MinimizeHost MinimizeAllSheets and StatusString have changed their data types to Variant e ShowControlPanel is an optional boo
153. bution Location parameter CB BatchFitND 53 Related Value Named Constant Value VBA Data Type Index Value Description e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Table 13 CB BatchFitND Value3 Parameter Optional Variant Related Value Named Constant Value VBA Data Type Value Description For Index 23 cbBftFitDistLockParam n a Double A number within the acceptable value range for the specified parameter according to Table 53 The actual value to be used for the specified parameter Cell references cannot be used here 54 Note Before you call CB BatchFitND reset the Crystal Ball simulation CB BatchFitND Example 1 This example resets the Crystal Ball simulation and fits all distributions to a columnar data set in cells Al through C500 including a header row The selected ranking method is Anderson Darling Results are output in a range on the current worksheet where D1 is the cell in the upper left corner Resulting assumption correlations are displayed in a matrix Correlations are established for assumptions whose absolute correlation is equal to or greater than 0 2 Goodness of fit and assumption reports are created with specified names The assumption report includes full statistics The l
154. cast cell CB SetFore Changes the settings for a forecast CB SetRange This subroutine sets the certainty range for one or all forecasts Note Run a simulation before calling this subroutine otherwise CB MacroResult returns cbErrNotReady To apply the subroutine to only one cell select that cell CB SetRange 223 Table 175 CB SetRange Parameters Parameter Min Optional VBA Data Type Variant Value Any number or cbMinuslnfinity Description Specifies the value of the low end of the certainty range and locks the certainty grabber there if greater than Infinity If only Minis set Max is set to Infinity and the grabber is unlocked If both Min and Max are set both grabbers are locked Max Optional Variant Any number or cbPlusinfinity Specifies the value of the high end of the certainty range and locks the certainty grabber there if less than Infinity If only Max is set Minis set to Infinity and unlocked If both Min and Max are set both grabbers are locked Certainty Optional Variant Any number between 0 and 100 Specifies the certainty level as a percentage to display lf Certainty and Min are both set Max is set to the appropriate value but is not locked If Certainty and Max are both set Min is set to the appropriate value but is not locked A11 Optional Variant True or False Specifies whether to apply this subroutine
155. cast using CB DefineForeND Before you call this function the forecast must exist Table 171 CB SetFore Returned Data Type Returned Value Whether the function was successful Variant Returned Data Type CB SetFitRange 219 Table 172 CB SetFore Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the forecast cell with the desired data Index Integer See Table 173 Sets certain forecast attributes according to Value Value Variant See Table 174 Works with Index to set certain forecast attributes Table 173 following describes the Index parameter Table 173 CB SetFore Index Parameter Values Required Integer Named Constant Value Index Value Description cbForName 1 Sets the forecast name according to Value cbForUnits 2 Sets the forecast units according to Value cbForAutoOpen 4 Changes whether Crystal Ball displays the forecast window automatically according to Value cbForOpenWhen 5 Changes when Crystal Ball displays the forecast window according to Value cbForPrecision 6 Changes whether Crystal Ball uses precision ofthe forecast value to stop a simulation according to Value cbForPrecisionAbsolute 7 Changes whether Crystal Ball uses absolute or relative terms for the size of the confidence interval according to Value cbForPrecisionAbsoluteValue 8 Sets the size of the confidence in
156. cations are able to run them on their computers The serial number is supplied by the Crystal Ball team for distribution through direct installation and licensing or through scripts and allows a certain number of activations Users of your applications can install and license Crystal Ball directly following instructions in the current Oracle Crystal Ball Installation and Licensing Guide Alternatively you can use a script for licensing also described in the Oracle Crystal Ball Installation and Licensing Guide Note C Users lt username gt Documents output txt Delivering Crystal Ball Runtime Applications 265 Startup Scripts Ideally users shouldn t need to manually start Crystal Ball You can use scripting to make sure that Crystal Ball automatically loads with Excel or you can start the Crystal Ball launcher file CBLauncher exe installed with Crystal Ball to make sure Crystal Ballstarts as follows e To ensure that Crystal Ballstarts automatically when Excel starts set the following registry Key to a value of 3 HKEY_CURRENT_USER Software Microsoft Office Excel Addins SecureCBAddin Connect LoadBehavior This is the same as checking the checkbox to automatically launch Crystal Ballwhen Excel starts in the Crystal BallApplication Manager Note Be sure to set the registry key value back to 2 when the application closes OR e To confirm that Crystal Ballis running before you run any Crystal BallDeveloper Kit code in the
157. cbChtDistType Integer type to a reverse cumulative frequency distribution For Index 3 cbGrp15 1 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of Lowest on the General tab of the Chart Preferences dialog For Index 3 cbGrp25 2 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of Low on the General tab of the Chart Preferences dialog For Index 3 cbGrp50 3 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of Low on the General tab of the Chart Preferences dialog For Index 3 cbGrp75 4 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of Medium on the General tab of the Chart Preferences dialog For Index 3 cbGrp100 5 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of High on the General tab of the Chart Preferences dialog For Index 3 cbGrp150 6 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of High on the General tab of the Chart Preferences dialog For Index 3 cbGrp300 7 Equivalent to the Chart cbChtGroups Boolean Bins Density setting of Highest on the General tab of the Chart Preferences dialog Crystal Ball Macro Calls Used With Specified Named Constant or Values of Index boolean Value Index Value Description For Index 5 True or False n a Turns on True or off cbChtMeanLine Boolean False the mean line For Index 6 True or False n a Turns on True or off cbChtHor
158. cbChtTrend CB EnumChart cbChtTrend CB CloseTrend CB CloseTrend Related Calls Name Description CB EnumChart Returns the unique name of the next chart of the specified type CB OpenTrend Opens the selected trend chart CB SelectChart Selects the chart with the specified chart ID CB CloseTrend 73 CB CopyData This subroutine stores a selected range definition for later use by CB PasteData which pastes all current Crystal Ball data of the selected type or types from the range stored by CB CopyData You can use CB CopyData with CB PasteData to quickly set up rows or columns of forecasts assumptions with similar distribution types or decision variables with similar bounds The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts Note Before calling this subroutine select a cell or cell range containing Crystal Ball data CB CopyData Example This example prompts you to select which data to copy either the assumption or forecast data It then copies only the selected data within the selected range Range selected below contains an assumption and a forecast Range B5 C7 Select contains an assumption and a forecast CB CopyData CB CopyData Related Calls Name Description CB CopyDataND Copies selected assumptions decision variables or forecasts CB PasteData Pastes assumptions decision variables or forecasts into
159. cbDfaGamma 1 CB GetLockFitParm Related Calls Name Description CB Fit Fits a specific probability distribution to a selected set of data range of cells CB GetFitParm Returns the value of the specified distribution parameter for the last CB Fit call CB GetLockFitParm 171 Name Description CB LockFitParm Sets parameter locking for distributions and optionally specific parameters CB SetFitRange Specifies the data range to be used as input for CB Fit CB GetRunPrefs This function returns run preference settings You can call this function from either a macro or a worksheet See Table 147 for a list of valid parameters Table 127 CB GetRunPrefs Returned Data Type Returned Value Returned Data Type The specified run preference setting Variant Note To call this function from a worksheet use the name CB GetRunPrefsEN Parameters are the ones listed in Table 147 and return the values listed there CB GetRunPrefs Example 1 This example puts the current settings for the first four run preferences into cells M10 through M13 In a macro you can enter the line For i 1 To 4 Range M9 Offset i 0 Value CB GetRunPrefs i Next i CB GetRunPrefs Example 2 This example puts the current sample size into the cell In a worksheet cell you can enter CB GetRunPrefsFN 8 CB GetRunPrefs Related Calls Name Description CB RunPrefs Changes simulation settin
160. cbRunMinimizeSheets Boolean True or False False minimizes worksheets during simulations True does not For Index 28 cbRunHideForecasts Boolean True or False True suppresses forecast and all other chart windows during simulations False does not For Index 29 cbRunMode Integer cbRunExtremeSpeed 1 cbRunNormalSpeed 2 cbRunDemoSpeed 3 Sets Crystal Ball to run in Extreme speed if available Normal speed or Demo speed depending on the named constant or index value listed in the Value column For Index 31 cbRunRandomSeed Long Any positive whole number Sets the seed value for using the same random sequence of numbers For Index 40 cbRunPrecisionControl Boolean True or False True uses precision control to stop the simulation False uses the maximum number of trials For Index 46 cbRunPrecision Confidence Double Any value between 0 01 and 99 99 Setting for cbRunPrecisionConfidence sets the confidence level as a percentage for precision control For Index 47 cbRunReversePercentiles Boolean True or False True makes percentiles represent the percentage of the distribution above the percentile value False makes percentiles represent the percentage below the value 198 Crystal Ball Macro Calls Used With Specified Values of Index For Index 48 cbRunFormatPercentiles Boolean Value True or False Description Determines
161. ccoo an deca RXRERETE RECHERCHER ays 160 CB GetExcel2007ForegroundMode s cs orion dae RRER TR AY 160 CB GetExcel2007ForegroundMode Example 4 4464004444444 44084008444 160 CE GetExcel2007PForegroundMode Related Calls 2 cscicsveveeawevieue cee 160 CEG REN un que parte a AAA AAA A AAA 160 CB Ge earn BXGDOE rior RR AAA 162 CAGAR ells radar daa esop 162 CDUGSIPIIe ura daa cio aa dido 162 CB GetFore Example T tests pes 164 CE Oa ROS COE 14 4133 4 6 34e ER de RO 9 e ERE e dee een ee IS A eT AELE A EEEE E AET EENALLE EEE TET 165 CB elForeData Example 1 22s pisar adria aia 165 CE GaPore ta ESP A ud AAA AAA 166 Contents ix x Contents CB GetForePercent E TERT nues nose E ns ee Be ad 166 CE GetForePercent Exemple L 424 akkarrbede x rs rra 166 CB GetForePercent Example2 A P CEU TELS 167 CB GetForePercent Related Calls Ea n ere adei sa 167 ORCOS LI es A AA ARA AAA AAA A AAA 167 CB GetForeStat Example 1 EIN ELET EEA TEETE ja aaa de E scu 169 CB GetForeStat Example2 ee OTE 169 CB GetForeStat Related Calls kan es 168 CB GetLockFitParm 0 ccirarisa O 170 CRGeLock ESURP E cos A erases 171 CB GetLockFitParm Related Calls or TT seus ee ee seas oe 171 E a ie hn wd oe Od he pa es kw ewe 172 CB GetRunPrefs Example 1 NN A TEST 172 CHAGetRunP els Example 2 oss cdccaeea va
162. cell B4 to Custom and passes the following values to it 10 20 30 40 CB SetDecVar CB SetDecVar Range B4 Range B4 cbDecType cbDecCustomData cbDecVarTypeCustom qu 20 30 40 CB SetDecVar 217 CB SetDecVar Related Calls Name Description CB DefineDecVar Defines or changes a decision variable in a selected cell using a dialog CB DefineDecVarND Defines or changes a decision variable in a selected cell without a dialog CB GetDecVar Retrieves information for a specific decision variable cell CB SetExcel2007ForegroundMode This function is used in Excel 2007 to set the Normal Speed preference Bring Excel 2007 to the foreground while running Normal speed simulations faster When set to True this call runs simulations at optimal speed when using Normal speed in Excel 2007 This call is equivalent to setting the referenced preference manually in the Normal Speed options dialog accessed by selecting Run Preferences then Speed then Normal Speed and then Options Table 169 CB SetExcel2007ForegroundMode Parameter Parameter VBA Data Type Value Description Enable boolean True or False Indicates whether to run Excel 2007 in the foreground when using Normal speed True is equivalent to manually checking the preference in the Normal Speed options dialog False is equivalent to manually unchecking the preference CB SetExcel2007ForegroundMode Example Th
163. centFiveNinetyFive 2 Specifies the 5th and 95th cbTwoDPercent Integer percentiles For Index 7 cbTwoDPercentQuartiles 3 Specifies quartiles 2596 ile cbTwoDPercent Integer increments from O to 100 inclusive For Index 7 cbTwoDPercentQuintiles 4 Specifies quintiles 20 ile cbTwoDPercent Integer increments from O to 100 inclusive 238 Crystal Ball Macro Calls Related Value Value or Named Constant Index Description For Index 7 cbTwoD cbTwoDPercentDeciles 5 Specifies deciles 10 ile Percent Integer increments from O to 100 inclusive For Index 7 cbTwoDPercentlcosatiles 6 Specifies icosatiles 5 ile cbTwoDPercent Integer increments from O to 100 inclusive For Index 7 cbTwoDPercentCustom 7 Defines custom percentiles cbTwoDPercent Integer supplied by an optional Value entry a one dimensional cell range containing percentiles If Value is omitted the default percentiles are 2 5 5 50 90 95 97 5 For Index 8 Integer from 2 to 250 n a Used with coTwoDMSDOption to cbTwoDMSDOption Integer specify the maximum number of uncertainty simulations to display in the output report and overlay chart Table 189 CB TwoDSimulationND Value2 Parameter Optional Variant Value or Named Related Value Constant VBA Data Type Index Description For Index 6 True or False boolean n a Indicates whether to cbTwoDOutputOption activate the specified Integer Value
164. centile data for extraction Table 69 Value Parameter Values that Support Index Constant cbExtPercentiles Named Constant Value Index Value Description cbPctQuartiles 1 Extracts quartiles 2596 cbPctQuintiles 2 Extracts quintiles 2096 cbPctDeciles 3 Extracts deciles 1096 cbPctlcosatiles 4 Extracts icosatiles 596 cbPctSet1 5 Extracts 2 5 5 50 95 97 5 iles cbPctSet2 6 Extracts 10 25 50 75 90 iles cbPctSet3 7 Extracts the 5 and 95 percentiles cbPctSet4 8 Extracts the 10 and 90 percentiles The following values are used with Index cbExtChooseAsm to specify assumption data for extraction Table 70 Value Parameter Values that Support Index Constant cbExtChooseAsm Named Constant Value Index Value Description cbChaaAll 1 Includes all assumptions cbChaChosen 2 Includes chosen assumptions Run this option after adding assumptions 128 Crystal Ball Macro Calls Named Constant Value Index Value Description cbChaAdd 3 Adds the assumption in the selected cell to the chosen assumptions Use cbChaChosen after this option cbChaClearList 4 Clears the list of chosen assumptions cbChaOpen 5 Includes all open assumptions The following values are used with Index cbExtStartSheet to specify whether data should be extracted to a new or existing workbook and worksheet Note Calling ExtractDataND with cbExtStartSheet will overwrite any settings made wi
165. cisionTableND reset the Crystal Ball simulation 96 Crystal Ball Macro Calls Table 45 CB DecisionTableND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 46 Index2 Optional Integer Table 47 Value Optional Variant Table 48 Table 46 CB DecisionTableND Index Parameter Required Integer Named Constant Value Index Value Description cbDecChooseTarget 1 Sets the target forecast for the decision table operates on the forecast in the currently selected cell cbDecChooseDecVar 2 Used with Index2 to select one or two decision variables for the decision table operates on the decision variable in the currently selected cell cbDecSimOption 3 Used with Index2 to set simulation options for the decision table cbDecForeOption 4 Used with Index2 to set forecast display options cbDecRun 5 Runs the Decision Table tool when all settings have been specified Table 47 CB DecisionTableND Index2 Parameter Optional Integer Related Value Named Constant Value Index Value Description For Index 2 cbDec cbChdAdd 3 Used with cbDecChooseDecVar ChooseDecVar Integer to add the decision variable in the selected cell to the list of chosen decision variables For Index 2 cbDec cbChdClearList 4 Used with coDecChooseDecVar ChooseDecVar Integer to clear the list of chosen decision variables For Index 3 coDecSimOption cbDecNumValuesVar1 1 Used with cb
166. ction calculates the certainty level or probability as a percent of achieving a forecast value at or below a specific threshold The value returned is equivalent to setting the right CB GetCBAutoLoad 151 endpoint grabber on the forecast chart to a specific value and obtaining the calculated certainty level You can call this function from either a macro or a worksheet For example suppose trial values for a forecast range from 5 to 300 If you enter 200 for the Value parameter see below CB GetCertainty would return the probability of obtaining a value within the range of 5 to 200 including those end points Note To call this function from a worksheet use the name CB GetCertaintyFN Table 99 CB GetCertainty Returned Data Type Returned Value Returned Data Type Certainty probability as a percent of achieving a value within a range from the minimum up Variant to and including the specified forecast value You must run a simulation before you call this function or it returns 0 Table 100 CB GetCertainty Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the forecast cell for which you want the In a worksheet B3 certainty value Value Double Any number Specifies the desired value CB GetCertainty Example 1 This example runs a simulation of 1000 trials and then pastes the certainty of the forecast in B7 being less than or equal to 15
167. custom application call CBLauncher exe as follows C Program Files Oracle Crystal Ball Bin CBLauncher exe where the installation folder part of this call should be modified if CB is installed on a non English machine or to a non default installation folder OR e Youcan use new Crystal Ball Developer Kit calls to open and close Crystal Ball and determine load status CB CBLoaded CB GetCBAutoLoad CB SetCBAutoLoad CB Shutdown and CB Startup For more information about these calls see Chapter 3 Crystal Ball Macro Calls Installing Crystal Ball Runtime To install your custom applications and Crystal Ball with a Runtime license instruct users to 1 Set Excel macro security to Medium recommended or Low using the following command sequence in Excel Tools then Options then Security and then Macro Security In Excel 2007 click the Office button and click Excel Options Then check Show Developer Tab In The Ribbon and click OK On the Developer tab choose Macro Security Then check Disable all macros with notification recommended or Enable all macros not recommended potentially dangerous code can run Note If you have attached a digital signature to the application xls or xla files this step is not necessary 2 Unzip your application Crystal Ball bundle by double clicking or other procedure depending on how it is constructed 266 Crystal Ball Runtime 3 Activate the installation and licensing scrip
168. d associated parameters Parmi Parm2 Parm3 All are optional Variant See Table 53 Parameter values for the distribution type specified with the DistType parameter LowCutOff Optional Variant Numeric Sets the lower truncation value The default is Infinity This parameter is ignored for custom distributions HighCutoff Optional Variant Numeric Sets the upper truncation value The default is Infinity This parameter is ignored for custom distributions NameOf Optional Variant Title surrounded by quotes Names the assumption If you do not t specify a name Crystal Ball uses the first of either the cell s range name text from the cell to the left text from the cell above or the cell s coordinates Dynamic Optional Variant True or False Specifies whether Crystal Ball calculates cell parameters once at the beginning of the simulation or with each trial Parm4 Optional Variant See Table 53 The minimum value for the 4 parameter beta distribution Note The optional Dynamic parameter is deprecated in this release It remains in the code for compatibility with 2000 5 5 5 versions of the Crystal Ball Developer Kit but will be obsolete in later versions because cell references are always dynamic in later versions of Crystal Ball Beginning with version 11 1 1 0 00 the lognormal distribution has three parameters instead of two If th
169. d If End Sub If you have stored the file CBDevKit xla in some other directory than C Program Files Oracle then substitute the appropriate path name This procedure gets a reference to the Excel application object and puts it into variable XL Then this variable is used to determine if Crystal Ball is already loaded If the Crystal Ball Developer Kit is not loaded the procedure loads it You cannot use Crystal Ball as an OLE automation object You should call its subroutines and functions through a call to Excel s Run macro The first parameter is the name of a Crystal Ball subroutine or function Other parameters are passed to the specified Crystal Ball call For example the following call to CB Simulation from a VBA module It is easy to translate code written in Visual Basic for Applications into Visual Basic code CB Simulation 1000 True can be replaced by the VB equivalent XL Run CB Simulation 1000 True Note Crystal Ball subroutine and function names are case sensitive when called from outside Excel Be sure to capitalize the CB module name that prefixes the call names In all other respects calling Crystal Ball from VB 4 0 is no different from calling it from VBA How to Use the Crystal Ball Developer Kit 25 26 o 0 10 0 5 NM 25 Y Creating an Excel Add in To create an Excel add in file In the VBA editor select Tools then Properties Select the Protection tab Select Lock Project For Viewing Enter
170. d Value Returned Data Type The absolute cell reference of the next forecast in the format workbook sheet a 1 Variant Note Call CB CheckData once at the beginning of an enumeration to reset the sequence of forecasts Call CB CheckData each time you add or delete data If the return string is empty all forecasts have been enumerated You can use the results of this function to create a Range object You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumFore Example This example runs a simulation initializes all internal variables and then steps through all the forecasts creates range objects from the returned string and opens the forecast window for each one Note that the range objects are created with absolute cell references CB EnumFore 121 CB CheckData Dim S As String Dim R As Range CB Simulation 1 s CB EnumFore While s lt gt 500 Set r Range s r Select CB OpenFore s CB EnumF Wend ore CB EnumFore Related Calls Name CB CheckData Description Checks assumptions for validity initializes variables CB EnumAssum Enumerates assumption cells for all open workbooks CB EnumDecVar Enumerates decision variable cells for all open workbooks CB GetFore Retrieves information for a specific forecast cell CB GetForePercent Returns a percentile for a forecast cell CB GetForeStat R
171. d range CB CopyDataND Copies selected assumptions decision variables or forecasts CB PasteData Pastes assumptions decision variables or forecasts into selected cells CB ClearData 69 CB ClearDataND This subroutine erases assumptions decision variables and forecasts from selected cells The values and formulas in the cells remain The worksheet must be active and the selected cell or range of cells must contain assumptions decision variables or forecasts Ifthe range contains more than one type of cell all types are cleared Unlike CB ClearData CB ClearDataND does not ask the user for confirmation Note Before calling this subroutine reset the current simulation and select a cell or cell range containing Crystal Ball data CB ClearDataND Example The following lines of code reset the simulation and clear the selected Crystal Ball data without any prompting CB ResetND CB ClearDataND The cell contents such as a value cell reference or formula remain CB ClearDataND Related Calls Name Description CB ClearData Erases assumptions decision variables and forecasts from selected cells after prompting CB CopyData Copies Crystal Ball data in specified range CB CopyDataND Copies selected assumptions decision variables or forecasts CB PasteData Pastes assumptions decision variables or forecasts into selected cells CB CloseAlICharts 70 This call closes all charts of a
172. e cbTwoDOutputOption specified va1ue1 Integer constant is active or not if set to True the specified items are included in the output report For Value1 A string containing an String n a Returns custom cbTwoDPercentCustom Excel range to hold percentile values desired percentile values specified for CB TwoDSimulationND CB GetTwoDSimulationOption Example 1 This example returns a constant that indicates the current forecast display option cbTwoDShowDefineFore cbTwoDShowTargetFore or cbTwoDHideFore CB GetTwoDSimulationOption cbTwoDForeOption CB GetTwoDSimulationOption Example 2 This example returns a set of custom percentile values The returned values are placed in the specified range in this case F20 H20 CB GetTwoDSimulationOption cbTwoDPercent cbTwoDPercentCustom F20 H20 CB GetTwoDSimulationOption Related Calls Name Description CB TwoDSimulation Launches the 2DSimulation tool CB TwoDSimulationND Runs the 2DSimulation tool without displaying dialogs CB GetVersion This function returns the version ID or build number of Crystal Ball Optional parameters VersionType and Index determine what is returned and how much of it appears 176 Crystal Ball Macro Calls Table 133 CB GetVersion Returned Data Type Returned Value Returned Data Type The version ID number or build number of Crystal Ball as a string Variant Table 134 CB GetVersion Parameters Value
173. e 120 Enumerates decision variable cells for all open workbooks CB EnumFore on page 121 Enumerates forecast cells for all open workbooks CB ExtractData on page 122 Extracts data from the current simulation and restored results optimization with an appropriate license or time series forecast using a dialog CB ExtractDataND on page 123 Extracts data from the current simulation and restored results optimization with an appropriate license or time series forecast without a dialog CB Fit on page 131 Fits a specific probability distribution to a range of data and returns information about the fit CB FormatPrefs on page 135 Opens the Chart Preferences dialog to set format preferences for the selected forecast CB FormatPrefsND on page 135 Sets format preferences for the selected forecast without a dialog CB Freeze on page 138 Defines which Crystal Ball data cells to hold to their spreadsheet values during a simulation using a dialog CB FreezeND on page 138 Defines which Crystal Ball data cells to hold to their spreadsheet values during a simulation without a dialog CB GetAssum on page 140 Retrieves information for a specific assumption cell CB GetAssumPercent on page 143 Calculates the value of the specified assumption that corresponds to the specified percentile CB GetBatchFitOption on page 144 Returns c
174. e Crystal Ball data version of the active or specified worksheet CB GetWorksheetVersion This function returns the Crystal Ball data version ID or build number for the active or specified worksheet It has three optional parameters The first optional parameter Worksheet indicates the target worksheet If omitted information is returned for the active worksheet The second optional parameter VersionType and the third optional parameter Index can return the full or partial version ID or build number as a string Note For Crystal Ball versions 7 0 through 7 1 2 the version ID returned is 7 0 0 This string changed starting with data created by Crystal Ball version 7 2 Table 135 CB GetWorksheetVersion Returned Data Type Returned Value Returned Data Type The Crystal Ball data version ID or build number returned for the active or specified worksheet Variant Table 136 CB GetWorksheetVersion Parameters Parameter VBA Data Type Value Description Worksheet Optional Worksheet An Excel object indicating Indicates the target the target workbook and worksheet whose version worksheet to return If omitted returns the version of the currently active worksheet VersionType Variant Oor1 Returns the Crystal Ball Optional version ID or build number as a string For details see Table 134 Index Optional Integer An integer from 1 to the Returns the specified number of sections in the portion of the versi
175. e Value parameter specified as A1 C100 or similar cbDataAnalysisDataOrientation Integer 3 Works with Value to specify whether data is in rows or columns cbDataAnalysisDatalnRows 1 cbDataAnalysisDatalnColumns 2 cbDataAnalysisSelectHeaders Integer 4 Uses a boolean value for the Value parameter to include column header text in the selection True include the top row of text cbDataAnalysisSelectLabels Integer 5 Uses a boolean value for the Value parameterto include row label text in the selection True include the first column of text cbDataAnalysisSelectLSL Integer 6 Sets the selected range of values as forecast LSLs lower specification limit for process capability analysis The range can either be specified as a separate line preceding the CB DataAnalysisND call such as A1 C10 Select or it can be the Value parameter specified as A1 C10 or similar cbDataAnalysisSelectUSL Integer 7 Sets the selected range of values as forecast USLs upper specification limit for process capability analysis See cbDataAnalysisSelectLSL for selection examples cbDataAnalysisSelectTarget Integer 8 Sets the selected range of values as forecast Targets target values for process capability analysis See cbDataAnalysisSelectLSL for selection examples cbDataAnalysisAutoOpenCharts Integer 9 Uses a boolean value for the Value parameter to indicate whether to open forecast charts automatically wh
176. e entered since they are required parameters for CB DefineDecVarND Ifa step size is entered for this decision variable type it is ignored Range F10 Select CB DefineDecVarND 0 1 Net Income cbDecVarTypeBinary CB DefineDecVarND Example 4 Crystal Ball example model Groundwater Cleanup xls contains two decision variables The decision variable in cell D13 is named Remediation Method It has a lower bound of 1 00 an upper bound of 3 00 and is defined as a Discrete decision variable with a step size of 1 00 Notice CB DefineDecVarND 111 that this definition yields three values expressed as integers 1 2 and 3 These are not numeric values but instead they represent three different remediation methods for groundwater cleanup This example model was included with Crystal Ball before new decision variable types were added Starting with Crystal Ball 11 1 1 0 00 this decision variable can be defined as the Category type shown in the following code Range D13 Select CB DefineDecVarND 1 3 1 Remediation Method cbDecVarTypeCategory This code defines a new decision variable in cell D13 that is identical to the one in Groundwater Cleanup xls except for the decision variable type It has a lower bound of 1 an upper bound of 3 a step size of 1 a title of Remediation Method and a decision variable type of Category Although a step size is entered for this decision variable type it is ignored CB DefineD
177. e inner variability simulation loop cbTwoDForeOption Used with Value to set forecast chart window display options cbTwoDOutputOption Used with va1ue1 to set output report options cbTwoDPercent Used with va1ue1 to specify percentile settings cbTwoDMSDOption Used with Valued to specify the maximum number of uncertainty simulations to display in the output report and overlay chart cbTwoDRun Runs the 2D Simulation tool Table 188 CB TwoDSimulationND Value1 Parameter Optional Integer Related Value Value or Named Constant Index Description For Index 2 cbTwoDAddAssumUncert 1 Used with cbTwoDChooseAssum Integer cbTwoDChooseAssum to add the selected assumption to the uncertainty simulation For Index 2 cbTwoDAddAssumVar 2 Used with cbTwoDChooseAssum Integer cbTwoDChooseAssum to add the selected assumption to the variability simulation For Index 2 cbTwoDAssumClearList 3 Used with cbTwoDChooseAssum Integer cbTwoDChooseAssum to return all unfrozen assumptions back to the uncertainty simulation For Index 3 Positive whole number integer n a Used with cbTwoDOuterSimTrials cbTwoDOuterSimfrials to specify the number of trials in CB TwoDSimulationND 237 Related Value Value or Named Constant Index Description the outer uncertainty simulation For Index 4 Positive whole number integer n a Used with coTwoDInner
178. e parameter SimChartType which specfies the type of chart to enumerate Table 60 CB EnumChart SimChartType Parameter Values Required Integer Named Constant Index Description cbChtOverlay 1 Enumerates overlay charts cbChtScatter 2 Enumerates scatter charts cbChtSensitiv 3 Enumerates sensitivity charts cbChtTrend 4 Enumerates trend charts CB EnumChart Example This example initializes all internal variables then steps through all the overlay charts returns their paths and names and puts this information in column C of a worksheet CB Simulation 1000 CB CheckData Dim ChartID As String Dim t As Integer ChartID CB EnumChart cbChtOverlay t 0 While ChartID lt gt Range C2 Offset t Value ChartID t t 1 ChartID CB EnumChart cbChtOverlay Wend CB EnumChart 117 CB EnumChart Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB CreateChart Creates a new chart of the specified type with the optional name if specified CB SelectChart Selects the chart with the specified chart ID CB EnumCorrelation This function lists correlated assumption cells and their correlation values for all open workbooks This command is useful for determining what correlated assumptions have been defined for the open workbooks You could then call CB GetAssum for each assumption to retrieve specific inf
179. e reference does not appear in the list continue with step 4 To locate and load the code module click Browse Browse to the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball Change Files Of Type to Microsoft Excel Files xls xla Double click CBDevKit xla CBDevkKit appears in the Available References list with a check in front of it Note If you upgraded from 2000 x 5 x versions of the Crystal Ball Developer Kit locate cb xla in the Available References list and uncheck it Click OK CBDevKit appears as a project where you can access the CB module Crystal Ball Developer Kit Overview Note If you do not create a reference to CBDevKit xla Crystal Ball calls will not be accessible from your VBA program Calling Crystal Ball From an External Visual Basic VB Program Using Crystal Ball from Visual Basic 4 0 or higher is somewhat more complicated than using it from Visual Basic for Applications To access Crystal Ball calls you must first get a reference to the Excel application object To do this run the following procedure before running Crystal Ball subroutines and functions Private Sub LoadCB On Error Resume Next Set XL CreateObject Excel Application Parent XL Visible True Set CB XL Workbooks CBDevKit xla Modules CB If Not IsObject CB Then Set CB XL Workbooks Open filename _ C Program Files Oracle Crystal Ball CBDevKit xla En
180. each included the chart False does not defines the percent scale forecast at a specified of the chart scale cbRptForePercentiles 7 Includes the percentile boolean True includes Integer See Table 32 statistics for each the percentiles False included forecast does not cbRptChooseFore 9 enables you to clear Integer See table n a add and set the list of Table 33 below forecasts to include in the report cbRptAssumParam 10 Includes the distribution boolean True includes n a parameters for each the parameters False included assumption does not cbRptAssumCharts 11 Includes the distribution boolean True includes Integer 1 to 200 graph for each included assumption at the specified scale the chart False does not defines the percent scale of the chart CB CreateRptND 81 Named Constant Value Index Value Description Value1 Optional Value2 Optional cbRptChooseAssum 12 Clears adds and sets Integer See table n a the assumptions to Table 34 below include in the report cbRptChartType 13 Selects the type of chart Integer See Table 35 n a to include in the report below cbRptOverlayChart 14 Includes all open overlay boolean True includes Integer 1 to 200 charts in the reportata the chart False does not defines the percent scale specified scale of the chart cbRptExistingSheet 16 Creates the report in an boolean True creates n a ex
181. each time you add or delete data If the return string is empty all decision variables have been enumerated You can use the results of this subroutine to create a Range object You can only call this function from a subroutine or another function You cannot call this function from a worksheet CB EnumDecVar Example This example initializes all internal variables then steps through all the decision variables creates range objects from the returned string and puts their absolute cell references in column B of a worksheet CB CheckData Dim S As String Dim R As Range Dim t As Integer S CB EnumDecvar 120 Crystal Ball Macro Calls While S lt gt Set R Range S Range B2 Offset t Value s L 9 sed S CB EnumDecVar Wend CB EnumDecVar Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB EnumAssum Enumerates assumption cells for all open worksheets CB EnumFore Enumerates forecast cells for all open workbooks CB GetDecVar Retrieves information for a specific decision variable cell CB EnumFore This function enumerates forecast cells for all open workbooks This command is useful for determining what forecasts have been defined for the open worksheets You can then call CB GetFore for each forecast to retrieve specific information for example the forecast name and units Table 64 CB EnumFore Returned Data Type Returne
182. eatures LSL USL and Target CB EnumAssum e Starting with Crystal Balll7 2 this function now returns absolute cell references CB EnumDecVar e Starting with Crystal Ball 7 2 this function now returns absolute cell references CB EnumFore e Starting with Crystal Ball 7 2 this function now returns absolute cell references CB ExtractDataND e The Extract Data feature and dialogs have changed substantially since Crystal Ball 2000 5 5 5 CB ExtractDataND has changed to support the new functionality o The Value constant cbDatForeValues 1 is deprecated in this release coDatValues 1 should be used instead o The description of Value constant cbChfChosen 3 corrects a documentation error Use this constant after cbChfAdd not cbChaAdd o The Value constant coDatCumulative 5 is not included in this release 254 Changes from Previous Versions o Anew Value constant coDatCapMetrics 7 is added for Index constant cbExtDataType 2 o Value constants cbPctSet3 7 and cbPctSet4 8 are added to support new product functionality o For Index constant cbExtExistingSheet 5 Value constants can be cbOKExistingSheet or cbOKNewSheet as well as True or False respectively o Additional Index constants are added cbExtChooseAsm 6 cbExtChartBins 7 and cbExtIncludeCellLoc 8 Crystal Ball 7 2 plus cbExtIncludeLabels 9 cbExtAutoFormat 10 cbExtSheetName 11 cbExtStartCell 12 and cbExtStartSheet 13 Crys
183. ecVarND Example 5 This example defines a new decision variable in cell G8 with a lower bound of 10 an upper bound of 40 no step size a title of Net Income and a decision variable type of Custom The values of Minand Maxare ignored for Custom decision variables but they must be entered since they are required parameters for CB DefineDecVarND If a step size is entered for this decision variable type it is ignored Range G8 Select CB DefineDecVarND 10 40 Net Income cbDecVarTypeCustom 10 20 30 40 Note that the data string the customData parameter can also be a valid cell range If the data string in the above code is stored in range A1 D1 the code becomes Range G8 Select CB DefineDecVarND 10 40 Net Income cbDecVarTypeCustom A1 D1 CB DefineDecVarND Related Calls Name Description CB DefineDecVar Defines or changes the decision variable in a selected cell using a dialog CB GetDecVar Retrieves information for a specific decision variable cell CB SetDecVar Changes certain attributes for a decision variable CB DefineFore This subroutine opens the Define Forecast dialog to create a new forecast or change an existing forecast in the selected cell The selected cell can be a simple value or formula cell You cannot define a forecast in a cell with an assumption 112 Crystal Ball Macro Calls Note Before calling this subroutine select a cell or cell range CB DefineFore Exa
184. ecifies the multisimulation method specifies analysis of custom percentiles included in the range F17 H17 specifies 100 bootstrap samples with 1000 trials per sample indicates that only the target forecast will display and then runs the Bootstrap tool CB ResetND Select target forecast A1 Select lt Al must contain a forecast CB BootstrapND cbBtsChooseTarget Select multisimulation method CB BootstrapND cbBtsMethod cbBtsMethodMultiSim Select what to analyze percentiles in this case CB BootstrapND cbBtsAnalyze cbBtsAnalyzePercent Select custom percentiles in the specified cell range CB BootstrapND cbBtsPercent cbBtsPercentCustom F17 H17 Set up sampling options 100 samples with 1000 trials per sample CB BootstrapND cbBtsSample cbBtsNumberSamples 100 CB BootstrapND cbBtsSample cbBtsTrialsPerSample 1000 Set display settings to show only the target forecast CB BootstrapND cbBtsForeOption cbBtsShowTargetFore Run Bootstrap CB BootstrapND cbBtsRun CB BootstrapND Example 2 This example runs the Bootstrap tool using default preferences or settings from a previous run in the current Excel session CB ResetND Run Bootstrap CB BootstrapND cbBtsRun CB BootstrapND Related Calls Name Description CB Bootstrap Launches the Bootstrap tool CB GetBootstrapOption Returns current settings for the Bootstrap tool CB CBLoaded This function determines if Crystal B
185. ed cb FormatPrefsND cbFmtDecimalPlace 3 CB FormatPrefsND Example 2 This example sets the format of the axis labels for all the forecasts to use the underlying cell format This overrides any other format preference until you turn it off CB FormatPrefsND cbFmtUnderlying True True CB FormatPrefsND 137 CB FormatPrefsND Related Calls Name Description CB ChartPrefs Sets chart preferences for the selected forecast or assumption using a dialog CB ChartPrefsND Sets chart preferences for the selected forecast or assumption without a dialog CB FormatPrefs Sets format preferences for the selected forecast using a dialog CB Freeze This subroutine displays a dialog so you can select which assumptions decision variables or forecasts will hold their worksheet values during simulations Note Before calling this subroutine activate a worksheet and reset the simulation CB Freeze Example This examp le activates Futura with OptQuest xls resets any previously run simulation and opens the Freeze dialog Workbooks CB ResetN CB Freeze Futura with OptQuest xls Worksheets Model Activate D CB Freeze Related Calls Name CB FreezeND Description Defines which assumptions decision variables or forecasts will hold their worksheet values during a simulation without using a dialog CB Reset Resets a simulation after prompting CB ResetND Resets a simulation without
186. eet or worksheet For example workbook to check for Worksheet Sheet1 Crystal Ball data CB IsCBObject Example This example checks to see whether user sheet is a worksheet object and not a module sheet or something else If it is a worksheet it checks the worksheet and its parent the workbook for Crystal Ball data If user sheet is not a worksheet or if no Crystal Ball data exist on either the worksheet or the workbook it displays an error message and exits the macro Otherwise it continues Set user sheet Worksheets Sheet2 If Not TypeName user sheet Worksheet Or Not CB IsCBObject user sheet Or _ CB IsCBObject user sheet Parent Then MsgBox Active document does not contain Crystal Ball Data Exit Sub End If CB IsCBObject 179 CB IsCBObject Related Calls Name Description CB MacroResult Tells you if a Crystal Ball macro call worked correctly CB Iterations This function returns the number of trials performed thus far in the simulation You can call this function from either a macro or a worksheet Table 139 CB Iterations Returned Data Type Returned Value Returned Data Type The number of trials already run in a simulation Variant Note To call this function from a worksheet use the name CB IterationsEN CB Iterations Example 1 This example runs a simulation for 1000 trials 100 trials at a time After each 100 trials the current number of
187. en the data analysis runs True automatically open charts 92 Crystal Ball Macro Calls Named Constant Value cbDataAnalysisSetViewType VBA Data Type Integer Index Value 10 Description If charts are shown takes cbChtChartType constants from CB ChartPrefsND as the va1ue parameter to determine which chart view appears See Table 24 for constants cbDataAnalysisFitToDistribution Integer 11 Uses a boolean value for the Value parameter to indicate whether forecast charts should be fitted to a distribution True fit to distributions cbDataAnalysisRankingMethod Integer 12 If cbDataAnalysisFitToDistribution is True works with Value to specify a ranking method for distribution fitting See Table 77 for constants cbDataAnalysisGenerateCorrela tionMatrix Integer 13 Uses a boolean value for the Value parameter to indicate whether rank correlations between forecast charts should be displayed in a matrix True generate matrix cbDataAnalysisRunOnAllModels Integer 14 Uses a boolean value for the Value parameter to indicate whether a simulation is run on all open workbooks at the same time the selected data is analyzed In this case forecast charts for all opened models appear with those generated from the data selected for analysis True run the simulation on all open workbooks this setting can be used for validating models cbDataAnalys
188. en version of Predictor added in version 11 1 3 0 00 o The following new Index constants are added cbRptPredictorChart 45 cbRptPredictorStatistics 46 coRptPredictorAutocorrelations 47 cbRptPredictorForecast 48 cbRptPredictorConfidenceIntervals 49 and cbRptPredictorMethods 50 o A new report section type is available as Value2 for cbRptSection cbRptSectPredictorSeries 10 o New Valuel constants are available for cbRptPredictorMethods cbPredictorMethodsNone 1 cbPredictorMethodsAll 2 cbPredictorMethods1Best 3 cbPredictorMethods2Best 4 cbPredictorMethods3Best 5 o Atenth integer is available for cbRptSectionOrder the cbRptSectPredictorSeries section is assigned number 10 CB DefineAltParms e An optional fourth parameter is added to support the version of the beta distribution used in versions later than Crystal Ball 2000 5 5 5 e cbParmMidpoint 20 and cbParmDegFreedom 21 are added to support the Student s t distribution added in Crystal Ball 7 0 e Logand geometric mean and standard deviation alternate parameter sets can now be used with lognormal distributions Note Because there are three alternate parameter sets in addition to percentiles for the lognormal distribution the cbParmRegular named constant cannot be passed to CB DefineAltParms when setting up an alternate parameter set for the lognormal distribution You must explicitly set the parameter set with for example cbParmLogMean
189. erating systems such as Windows XP Window Server 2003 or Windows Vista 64 bit To prevent runtime errors in this environment configure your build properties to set the target platform to x86 OptQuest Developer Kit Namespace The OptQuest Developer Kit contains the following main namespace in Visual Basic code Decisioneering CB CBCOMDevKit This namespace contains the classes required to set up and run an optimization with the OptQuest Developer Kit Important OptQuest Classes Two categories of important classes in the OptQuest Developer Kit e Optimization Setup Classes on page 271 e Optimization Runtime Classes on page 272 For lists and descriptions of methods and properties in these classes open CB Com Devkit chm in the Docs folder beneath the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball You can use this file as a reference at any time For more information on this help system and how to use it see CB Com Devkit chm on page 274 Optimization Setup Classes The following are the main OptQuest Developer Kit classes used for setting up an optimization e OptSetup main class for setting up optimizations e OptSetup Constraint e OptSetup Decision OptQuest Developer Kit Use and Structure 271 e OptSetup Objective e OptSetup OptEfficientFrontier e OptSetup OptOptions e OptSetup Requirement OptSetup This class is the main class for setting up optimizations You can
190. err A srai 193 CB RestoreResultsND Hr LOA CB RestoreBesultsND Exat ple carros Re ERE RR ARA E RE GR RR 194 CB RestoreResultsND Related Calls Ried ded ads ee 194 COI a a apiid do ie qe CORP d DEOR A qe aee deno 194 CR Run eR PANPE 2 qu ves boop ieee sequen sean rv di 194 CH RunPreb Relied Calls o2a2suqeqaawxes zacsur AAN 195 LIPPE uada qct no FR ICE RO e Plc aO DICE Gd e bo doc a e CR C Re A 195 Contents xi CB RunPrefsND Example ee es x edes ads xd 199 CE RunPreND Related Calls agen gene ae good oe eee ee Oe Y 200 CB RuntuneMode orcos PAE EE PEE EE O EIS 200 CB RuntimeMode Example ToT ETET TERT 200 CB RunimeMode Related Call ici tirinte GC ERE FX ERG 201 Charm 122a pesce og ata pad bu EL 201 CB SaveResults Example AA M ne Re 201 CB SaveResults Related Calls Sees ee Boas ace ee ddr ims se 201 CUASI a coa ad dada eed dep S dud 202 CB SaveResultsND Example erradicar Koi ied 202 CB SaveResultsND Related Calls T n Sg BILE Ru oor s 202 G A E Re OR ee ee E E E a E E E 202 CB ScatterPrefs Example nnneermn 203 CB ScatterPreis Related Call cir kae a CR CRGO CK CROCO RON CN 203 CESAR cria lega Yu vl oe oO ENER OE sa a COSSIO ip Lise gd sake VK AA ARA TATEM S 206 Ch Scatter Prep Belated Call cocida d rss qp d pr ao ed 207 CB Select ssum bs TT pius oe bus 25 xus
191. ersions CB CopyData and CB CopyDataND Data is no longer copied to Crystal Ball s internal clipboard Instead these calls record a range of data to be pasted All Crystal Ball data within that range is pasted when CB PasteData runs For this reason CB PasteData should be called immediately after CB CopyData or CB CopyDataND before any data is changed within the copied range For CB CopyDataND the documentation is corrected to match the code parameter CBData is renamed DataType CB CorrelateND A new optional parameter SecondAssum is added to specify a second cell to correlate with the cell specified by the first parameter The cell specified by SecondAssum can be on another worksheet in the same workbook CB CreateRpt Can now be called while a simulation is running CB CreateRptND Can now be called while a simulation is running Is substantially changed to support the revised Create Report command in Crystal Ball 7 x and later including 11 x O O The Index constant cbRptForeFrequencies 8 is removed obsolete Index constant cbRptDecVar 15 is deprecated cbRptChooseDecVar 18 should be used instead Index constant RptExistingSheet 16 is changed so that True creates the report on a new sheet instead of the existing sheet of the current workbook while False creates the report in a new workbook New Index constants with index values of 17 26 28 30 and 32 37 are added as described in Table 31 Additio
192. es sensitivity cbMesRankCorrelation or by rank correlation False cbMesContributionToVar uses contribution to variance For Index 5 Boolean True or False n a True displays only a certain number Value2 of CB SensPrefSND 211 Used With Specified Named Constant or Values of Index boolean Value Index Value Description sensitivities False does not For Index 6 Boolean True or False n a True only displays sensitivities over Value2 For Index 7 String Title in quotes n a Defines the sensitivity chart title For Index 8 Integer cbChaAll 1 Includes all assumptions For Index 8 Integer cbChaAdd 3 Adds the assumption in the selected cell to the list of chosen assumption For Index 8 Integer cbChaClearList 4 Clears the list of chosen assumptions For Index 8 Integer cbChaRemove 6 Removes the assumption in the selected cell from the list of chosen assumptions Table 158 following lists values for the optional Value2 parameter Table 158 CB SensPrefsND Value2 Parameter Values Optional Variant Used With Specified Values of Index Value Description For Index 5 Integer A positive whole number Sets the maximum number of sensitivities to display For Index 6 Double A positive number between 0 00 and Sets the minimum sensitivity values 1 00 to display CB SensPrefsND Example The following example runs a simulation selects cell B2 defines
193. ess of the selected Batch Fit data range in the format workbook sheet A 1 Z 100 144 Crystal Ball Macro Calls Named Constant Value cbBftInputOrientation Index Value Description Returns a constant to indicate whether the data cells are in rows or columns cbBftInputRows 1 or cbBftInputColumns 2 cbBftInputHeader Returns a boolean to indicate whether the input range has a header True cbBftInputLabel Returns a boolean to indicate whether the input range has a label True cbBftSelectDist Returns an array of cbDfa assumption distribution integers as listed in Table 53 cbBftRankMethod 11 Returns the constant of the selected fit ranking method as listed in Table 77 cbBftOutputLocation 12 Returns the constant of the selected output location setting a new workbook the current workbook a new worksheet or the current worksheet cbBftNewWorkbook 1 cbBftCurrentWorkbook 2 cbBftNewWorksheet 3 or cbBftCurrentWorksheet 4 If coBftCurrentWorksheet is returned you can use cbBftOutputLocationCell 25 to return the starting cell cbBftOutputFormat 13 Returns a boolean to indicate whether the output is formatted True cbBftOutputCorrelationMatrix 14 Returns a boolean to indicate whether a correlation matrix is produced True cbBftOutputCorrelation 15 Returns a boolean to indicate whether assumptions above a ce
194. est explicitly call CB AutoDownshift and set it to False Table 7 CB AutoDownshift Returned Data Type Returned Value Returned Data Type The current TurnOn parameter setting boolean Table 8 CB AutoDownshift Parameters Parameter VBA Data Type Named Constant Value Description TurnOn Variant True or False True turns on automatic downshifting from Extreme speed to Normal speed False turns it off CB AutoDownshift Example 1 This example sets Crystal Ball to automatically downshift to Normal speed when a model cannot run in Extreme speed and returns TRUE in cell B2 Range B2 Value CB AutoDownshift True CB AutoDownshift 45 CB AutoDownshift Example 2 To retrieve the current setting of CB AutoDownshift use this call in a function in the following form ReturnValue CB AutoDownshift CB BatchFit This call launches the Batch Fit tool wizard This tool helps define assumptions when you have historical data for a number of variables The tool automatically selects which probability distribution binomial normal triangular uniform and so on best fits each series of historical data and returns the parameters to use in your model Batch Fit can also provide a table of goodness of fit statistics and a correlation matrix calculated between the historical data Note Before calling CB BatchFit reset the simulation CB BatchFit Example This example resets the Crystal Ball simulation and
195. esultsND Related Calls Name Description CB RestoreResults Restores simulation results from a file using a dialog CB RestoreResultsND Restores simulation results from a file without a dialog CB SaveResults Saves current simulation results using a dialog CB Simulation Runs a Crystal Ball simulation CB ScatterPrefs This call pens the Scatter Preferences dialog for the selected scatter chart either open or closed If more than one scatter chart is found this call opens a chooser dialog If no scatter chart has 202 Crystal Ball Macro Calls been defined this call creates a new chart with no selected assumptions or forecasts using the default preferences This chart then becomes the selected chart for subsequent scatter chart calls Tf this call is used and a simulation has not been run the macro returns error 5009 CB ScatterPrefs Example The first call in this example runs a simulation The second call either creates a scatter chart selects a single scatter chart or opens a chooser dialog if there are multiple scatter charts and then opens the Scatter Preferences dialog for the selected scatter chart CB Simulation 1000 CB ScatterPrefs CB ScatterPrefs Related Call Name Description CB ScatterPrefsND Sets preferences for the specified scatter chart CB ScatterPrefsND This call sets preferences for the selected scatter chart If more than one scatter chart is open and no chart is selected
196. eters whether or not the distribution needs three Thatis ifa distribution uses only one ortwo parameters you must still supply three using the cbParmNone parameter to round out the argument list For more information see Table 51 Parm4 Optional Variant Named constant or other value Specifies an optional fourth alternate parameter currently required only for the beta distribution The following constant and index values shown in Table 51 can be used with Parm1 Parm2 Parm3 and Parm4 described in Table 50 Table 51 CB DefineAltParms Parm1 Through Parm4 Constant and Index Values Named Constant Index Value Description cbParmNone 1 Placeholder in the parameter list for distributions that require fewer than three parameters This parameter must come at the end of the argument list See the examples for how to use this parameter cbParmRegular 2 Regular parameter for the distribution for example the mean or standard deviation for the normal distribution You can t use this parameter for lognormal distributions cbParmLogMean 3 Log mean cbParmLogStDev 4 Log standard deviation cbParmGeoMean 5 Geometric mean cbParmGeoStDev 6 Geometric standard deviation cbParmMean 1 Mean cbParmStDev 8 Sandard deviation cbParmMinimum 9 Mnimum value cbParmLikeliest 10 Lieliest value cbParmMaximum 11 Maximum value 100 Crystal Ball Macro Calls
197. ets the size of the confidence interval in cbForPrecisionRelativeValue Double relative percentage terms For Index 10 cbForPrecisionMean Boolean True or False True checks the precision of the mean False does not For Index 11 cbForPrecisionStdDev Boolean True or False True checks the precision of the standard deviation False does not For Index 12 cbForPrecisionPerc Boolean True or False True checks the precision of a percentile False does not For Index 13 cbForPrecisionPercValue Double 0 01 to 99 99 Sets the percentile value that Crystal Ball checks for precision For Index 14 cbForFilter Boolean True or False True turns on forecast filtering False turns it off For Index 15 cbForFilterlnside Boolean True or False True discards values inside the filtering range False discards values outside the range For Index 16 cbForFilterFrom Double Units Sets the lower bound of the filtering range For Index 17 cbForFilterTo Double Units Sets the upper bound of the filtering range For Index 18 cbForFilterGlobal Boolean True or False True applies the filtering settings to equivalent trials for all forecasts in a simulation False applies them only to the current forecast For Index 19 cbForFrozen Boolean True or False True freezes the forecast so it will not recalculate when a simulation runs False unf
198. eturned Value The distribution parameter for the last CB Fit as specified by Index Returned Data Type Variant Note Before calling this function call CB Fit or the function returns 0 CB GetFitParm has one parameter Index an integer The Index parameter specifies which distribution parameter value to return Its has only four values 1 2 3 and 4 The following table shows which values are returned for each distribution Table 114 CB GetFitParm Index Parameter Values Required Integer Last Distribution Index 1 returns Index 2 returns Index 3 returns Index 4 returns Normal mean standard deviation n a n a Triangular minimum likeliest maximum n a Lognormal mean standard deviation location n a Uniform minimum maximum n a n a Exponential rate n a n a n a Weibull location scale shape n a Beta alpha beta maximum minimum Gamma location scale shape n a Logistic mean scale n a n a Pareto location shape n a n a Extreme value likeliest scale max True or min n a False Minimum extreme likeliest scale n a n a value Maximum extreme likeliest scale n a n a value Student s t midpoint scale degrees of freedom n a BetaPERT minimum likeliest maximum n a Note The parameters for beta have changed since Crystal Ball 2000 x 5 x There are now four parameters Extreme value is deprecated It is included for Crystal Ball 2000 5 5 5 compati
199. eturns a statistic for a forecast cell CB ExtractData This function extracts simulation data It opens the Extract Data dialog so you can specify the data to extract and then extract it Only call this function after you run a simulation optimization time series forecast or restore saved results Use CB CheckData before using this call CB ExtractD ata Example This example opens the Extract Data dialog CB Simulation 1 CB CheckData CB ExtractData 122 Crystal Ball Macro Calls 000 CB ExtractData Related Calls Name Description CB CreateRpt Creates a report from the current simulation and restored results optimization or time series forecast using a dialog CB CreateRptND Creates a report from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractDataND Extracts data from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractDataND This function extracts Crystal Ball data from the the current simulation For any preferences not explicitly set the default is the current setting in the Extract Data dialog Use CB CheckData before using this call You can extract more than one type of data For details see CB ExtractDataND Example 2 Note Before calling this function run a simulation OptQuest optimization or Predictor time series forecast Table 65 CB ExtractDataND Pa
200. ey support new Crystal Ball tools and parameter locking features in distribution fitting CB BatchFit CB BatchFitND CB Bootstrap CB BootstrapND CB DataAnalysis CB DataAnalysisND CB DecisionTable CB DecisionTableND CB LockFitParm CB GetBatchFitOption Introduction 245 CB GetBootstrapOption CB GetDataAnalysisOption CB GetDecisionTableOption CB GetLockFitParm CB GetTwoDSimulationOption CB TwoDSimulation CB TwoDSimulationND Added in Crystal Ball 7 1 7 3 x The following new calls have been added to previous versions of the Crystal Ball Developer Kit since Crystal Ball 2000 5 5 5 An asterisk indicates that the call has changed from the previous version in some way Check Changes to Existing Calls on page 249 for details CB AlertOnArgumentError CB AlertOnMacroResultError CB AlertOnObsolete CB AutoDownshift CB CBLoaded CB CheckDataND CB CloseAllCharts CB CloseChart CB CloseSensitiv CB CloseTrend CB CopyScatter CB CopySensitiv CB CopyTrend CB CreateChart CB DefineAltParms CB DeleteChart CB EnumChart CB EnumCorrelation CB Fit CB Freeze CB FreezeND 246 Changes from Previous Versions CB GetCBAutoLoad CB GetExcel2007ForegroundMode CB GetFitParm CB GetForeData CB GetVersion CB GetWorksheetVersion CB MacroResultDetail CB OpenChart CB OpenSelection CB OpenSensitiv CB OpenTrend CB RestoreResults CB RestoreResultsND CB RuntimeMode CB SaveResults CB SaveResultsND CB SelectChart CB SensP
201. ferences dialog CB ChartPrefs This subroutine opens the Chart Preferences dialog for the selected assumption or forecast cell so you can change the chart preferences If an assumption or forecast cell is not selected error code 5102 appears from CB MacroResultDetail NewValue Before calling this subroutine to change the chart preferences for a particular assumption or forecast chart select the corresponding cell CB ChartPrefs 63 Note Requirements for this subroutine are slightly different than for Crystal Ball 2000 5 5 5 For 2000 x 5 x versions you could use this subroutine without selecting a cell to set default forecast chart settings CB ChartPrefs Example This example runs a simulation of 500 trials selects cell B7 and then opens the Chart Preferences dialog CB Simulation 500 Range B7 Select CB ChartPrefs CB ChartPrefs Related Calls Name Description CB ChartPrefsND Sets chart preferences for the forecast or assumption corresponding to the selected cell without displaying the Chart Preferences dialog CB Simulation Runs a Crystal Ball simulation CB ChartPrefsND 64 This subroutine sets chart preferences for the forecast or assumption corresponding to the selected cell without displaying the Chart Preferences dialog The default for any preference is the previous setting in the Chart Preferences dialog Note You must select a forecast or assumption cell before calling this subro
202. for fitting a range address string The range must be contiguous adjoining cells cbBftInputOrientation Integer Used with va1ue1 to specify whether the data cells are in rows or columns cbBftinputHeader Integer Used with va1ue1 to indicate whether the input range has headers If set to True there is header text in the top row or first column depending on the cbBftInputOrientation setting cbBftInputLabel Integer Used with va1ue1 to indicate whether the input range has labels If set to True there is label text in the first column or top row depending on the cbBftInputOrientation setting cbBftSelectDist Integer Used with Value to choose a specific distribution to fit takes cbDfa distribution constant as specified in Table 75 cbBftSelectDistAll Integer Chooses all available continuous and discrete distributions to fit cbBftSelectDistClear Integer Clears all distributions currently selected for fitting cbBftSelectDistAllContinuous Integer Chooses all available continuous distributions to fit cbBftSelectDistAllDiscrete Integer Chooses all available discrete distributions to fit CB BatchFitND 47 Named Constant Value cbBftSelectDistAuto VBA Data Type Integer Index Value 10 Description Automatically chooses which distributions to fit cbBftRankMethod Integer 11 Used with Value to choose a ranking met
203. for assumption cells CB GetFore Retrieves information for a specific forecast cell CB GetForeStat Returns statistics for forecast cells CB GetForeStat This function calculates the specified statistic for the forecast in the specified cell You can call this function from either a macro or a worksheet Run a simulation before calling this function or else it returns 0 Note To call this function from a worksheet use the name CB GetForeStatEN Table 122 CB GetForeStat Returned Data Type Returned Value Returned Data Type The specified statistic for the forecast Variant Table 123 CB GetForeStat Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 In Points to the forecast cell a worksheet B3 for which you want the statistic Index Integer See Table 124 Calculates the specified statistic for the forecast in the specified cell using the values listed in Table 124 CB GetForeStat 167 Use the following Index named constant and index values Table 124 to return forecast statistics for the selected cell Table 124 CB GetForeStat Index Parameter Values Required Integer Named Constant Value Index Value Description cbFstTrials 1 Returns the number of trials cbFstMean 2 Returns the mean cbFstMedian 3 Returns the median cbFstMode 4 Returns the mode cbFst
204. fsND on page 195 e CB ScatterPrefs on page 202 e CB ScatterPrefsND on page 203 e CB SensPrefs on page 210 e CB SensPrefsND on page 210 e CB SetExcel2007ForegroundMode on page 218 e CB TrendPrefs on page 231 e CB TrendPrefsND on page 232 36 Crystal Ball Developer Kit Overview Crystal Ball Tools The macro calls described in the following sections are used to launch Crystal Ball tools access tool functionality without displaying dialogs or return information about tool settings CB BatchFit on page 46 CB BatchFitND on page 46 CB Bootstrap on page 55 CB BootstrapND on page 56 CB DataAnalysis on page 91 CB DataAnalysisND on page 91 CB DecisionTable on page 96 CB DecisionTableND on page 96 CB GetBatchFitOption on page 144 CB GetBootstrapOption on page 148 CB GetDataAnalysisOption on page 154 CB GetDecisionTableOption on page 156 CB GetTwoDSimulationOption on page 173 CB TwoDSimulation on page 236 CB TwoDSimulationND on page 236 Special Calls The macro calls in this group can be used to Display the About box Enumerate assumptions decision variables and forecasts Determine if a worksheet or workbook contains Crystal Ball data Determine how many trials have run in a simulation Hide the Crystal Ball user interface in custom applications The subroutines and functions described in the followi
205. g CB SaveResultsND Saves current simulation results data charts and reports without a dialog CB RestoreResultsND This subroutine automatically restores simulation results from the file specified by Fi1eName See CB RestoreResults for more information about what is restored CB RestoreResults 193 To run this subroutine you must have a saved cbr file or CB MacroResult returns cbErrRestoreResult You can restore any number of results files at one time but they must be restored one at a time You do not need to reset the current simulation before you run this subroutine You can restore results while a simulation is running completed or stopped If the file could not be read or is not a Crystal Ball results file CB MacroResult returns cbErrRestoreResult CB RestoreResultsND is similar to CB RestoreRunND available in Crystal Ball 2000 5 5 5 However CB RestoreRun and CB RestoreRunND restored an entire simulation saved with CB SaveRun or CB SaveRunND not just the results The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored ata time Table 146 CB RestoreResultsND Parameters Parameter VBA Data Type Value Description FileName String A path surrounded by Points to the saved results quotes such as C file to restore temp sheet2 cbr See the Oracle Crystal Ball User s Guide for more information on saving simulation results
206. get Forecast set with cbDecShowTargetFore 3 Hide All Forecasts set with cbDecHideFore Table 108 CB GetDecisionTableOption Index2 Parameter Optional Integer Named Constant Value cbDecVar1 Index Value Description Used with cbDecGetDecVar to return the address of the first selected decision variable in the format workbook sheet A 1 cbDecVar2 Used with cbDecGetDecVar to return the address of the second selected decision variable in the format workbook sheet A 1 cbDecNumValuesVar1 Used with cbDecSimOption to return the number of test values to use for the first selected decision variable cbDecNumValuesVar2 Used with cbDecSimOption to return the number of test values to use for the second selected decision variable cbDecSimTrials Used with cbDecSimOption to return the maximum number of trials for each simulation CB GetDecisionTableOption 157 CB GetDecisionTableOption Example The following example returns information for the Decision Table definition created in CB DecisionTableND Example and stores it in cells M6 through M12 Gets the address of the target forecast Gets the maximum number o Range M6 Value CB GetDecisionTableOption cbDecGetTarget Gets the address of the first and second selected decision variables Range M7 Value CB Ge Range M8 Value CB Ge tDecisionTableOption cbDecGetDecVar cbDecVarl DecisionTa
207. gs using a dialog CB RunPrefsND Changes simulation settings without a dialog 172 Crystal Ball Macro Calls CB GetTwoDSimulationOption This function returns specified settings made by CB TwoDSimulationND or the 2D Simulation tool Table 128 CB GetTwoDSimulationOption Returned Data Type Returned Value The specified 2D Simulation settings Variant Returned Data Type Table 129 CB GetTwoDSimulationOption Parameters Parameter Required VBA Data Type Table Index Required Integer Table 130 Valuel Optional Integer Table 131 Value2 Optional Variant Table 132 Table 130 CB GetTwoDSimulationOption Index Parameter Required Integer Value or Named Constant cbTwoDGetTarget Index Description Returns the address of the selected target forecast for the 2D simulation operation operates on the forecast in the currently selected cell use cell Select first to select the cell cbTwoDGetAssum Works with value to enumerate the list of assumptions by type uncertainty or variability returns a string containg the full name cell address of the cells Each successive call returns the next assumption in the list cbTwoDOuterSimTrials Returns the number of trials in the outer uncertainty simulation loop cbTwoDInnerSimTrials Returns the number of trials in the inner variability simulation loop cbTwoDForeOption Returns the Value constant that indicate
208. h Valued Table 185 following describes the Value3 parameter 234 Crystal Ball Macro Calls Table 185 CB TrendPrefsND Value3 Parameter Values Optional Variant Used With Specified Parameters and Values Value Description For Index 7 and Valuel 3 Any number Defines the maximum value for the Double value axis For Index 8 Integer Any integer between O and 100 Sets a third certainty band to display inclusive Use this with va1ue1 and value2 When Value1 is coChfA dd the active cell must contain a forecast otherwise CB MacroResult returns cbErrNoForecastInCell Crystal Ball adds the selected cell to the list of forecasts to appear in the trend chart To display a specific set of forecasts in a certain order on the trend chart first clear the list of selected cells by calling this macro with value1 set to cbChfClearList Then for each forecast use Range Select to highlight the desired forecast cell and call this macro with value1 set to cbChfAdd You can set the percentage values of as many as seven certainty bands Set Index to cbTrdCertaintyBands and supply the percentage values in Va1ue1 through va1ue7 They will appear in the trend chart in the order that you define them so define them from smallest to largest or from largest to smallest See the Oracle Crystal Ball User s Guide for more information on how to customize the trend chart CB TrendPrefsND Example This example runs a simulation of
209. hEvents PortfolioOptRuntime As CBCOMDevKit OptRuntime Private PortfolioOptSetup As CBCOMDevKit OptSetup Private ObjectiveTotal As CBCOMDevKit Objective Private RequirementRisk As CBCOMDevKit Requirement Private ConstraintFunds As CBCOMDevKit Constraint Private DecisionFundl As CBCOMDevKit Decision Private PortfolioWorkbook As Workbook Private InvestmentModel As Worksheet Private Options As CBCOMDevKit OptOptions Next it opens the subroutine that actually performs the optimization and defines error handling Sub RunOptimization RunEF As Boolean On Error GoTo ErrorHandling From there it creates instantiates Setup and Runtime objects and resets the optimization Set PortfolioOptSetup New CBCOMDevKit OptSetup Set PortfolioOptRuntime New CBCOMDevKit OptRuntime PortfolioOptRuntime Reset Developing Optimization Code 277 This subroutine goes on to e Close any open worksheets e Create a new Portfolio Allocation workbook e Clear any previous OptQuest data e Select a primary workbook for optimization e Set up the investments e Set up the optimization e Set up Efficient Frontier analysis if requested e Configure any options e Run the optimization show the Control Panel e Get and display the optimization results e Modify the OptQuest Results window display Most of those operations are performed by calling subroutines All code is heavily commented for easier understanding
210. hartcan now be explicitly selected via CB EnumChart and CB SelectChart before it can be opened CB PasteData e This subroutine no longer pastes from Crystal Ball s internal clipboard Instead it pastes all Crystal Ball data currently existing within the range specified by CB CopyData or CB CopyDataND to the extent that appropriate value or formula cells exist within the range selected for pasting For best results use this subroutine immediately after CB CopyData or CB CopyDataND CB RunPrefsND e The following Index constants used in Crystal Ball 2000 5 have changed as indicated o cbRunBurstMode 5 obsolete and removed from the code o cbRunResetToOriginal 6 obsolete and removed from the code o cbRunSensitivAnalysis 9 obsolete and removed from the code o cbRunRetainUnsortedTrials 11 obsolete and removed from the code o cbRunPrecisionWithin 45 obsolete and removed from the code o cbRunLeaveOpenOnReset 50 new in Crystal Ball 7 0 o cbRunMacroBeforeSimul 21 obsolete and removed from the code replaced by cbRunUserMacros 51 o cbRunMacroBeforeRecalc 22 obsolete and removed from the code replaced by cbRunUserMacros 51 258 Changes from Previous Versions o cbRunMacroAfterRecalc 23 obsolete and removed from the code replaced by cbRunUserMacros 51 o cbRunMacroAfterSimul 24 obsolete and removed from the code replaced by cbRunUserMacros 51 o cbRunMinimizeSheets 27 changed to work as described in t
211. he Value parameter section of Table 147 o In Crystal Ball 2000 5 5 5 values for cbRunMode 29 were booleans in later versions of Crystal Ball the values are integers Models from Crystal Ball 2000 x that use this constant will not run successfully in later versions of Crystal Ball until the constant values are edited o cbRunParadiseServer 30 obsolete and removed from the code o cbRunBurstAmount 33 obsolete and removed from the code o New constants added include cbRunPrecisionWithin 45 coRunPrecisionConfidence 46 coRunFormatPercentiles 48 coRunSaveAssumptionValues 49 cbRunUserMacros 51 coRunCapMetrics 52 coRunCapMetricsShort 53 cbRunCapMetricsShift 54 coRunCapMetricsCalcType 55 cbRunCapMetricsNormalityThresh 56 cbRunCapMetricsNormalCalcOptions 57 e cbRunPrecisionMean 41 used in versions before Crystal Ball 2000 5 5 5 is now obsolete e The equivalent Valuel and Value 2 constants are removed or added as appropriate CB SensPrefsND e cbSenIncludeAssum 3 is now obsolete coSenChooseAssum 8 is used in its place e cbSenIncludeOtherFore 4 is now obsolete e cbSenTitle 7 has been added CB SetAssum e Data type returned changes from boolean to Variant e The first parameter name is changed from AssumRef to AssumReference to correct a documentation error e The data type of the first parameter is changed from Range to Variant CB SetDecVar e Data type returned changes from
212. here to the left of the underscore will change depending on the variable name assigned to OptRuntime BeforeOptimizationEvent Private Sub PortfolioOptRuntime_BeforeOptimizationEvent your code is here End Sub BeforelterationEvent Private Sub PortfolioOptRuntime BeforeIterationEvent Your code is here End Sub User defined Event Macros for Optimizations 281 BeforeSimulationEvent Private Sub PortfolioOptRuntime_BeforeSimulationEvent Your code is here End Sub AfterSimulationEvent Private Sub PortfolioOptRuntime AfterSimulationEvent _ IterationsCompleted As Long Trials As Long _ MaxTrials As Long _ Progress As Double _ WasAborted As Boolean WasStoppedOnError As Boolean WasStoppedOnPrecision As Boolean _ HasNewBestSolution As Boolean your code is here End Sub In this signature parameters or arguments are defined as follows e IterationsCompleted Number of iterations completed e Trials Number of trials completed for this simulation e MaxTrials Number of trials scheduled to run total trials per simulation e Progress Percent of trials completed expressed as a decimal 0 to 1 0 e WasAborted True if manually stopped e WasStoppedOnError True if stopped on error e WasStoppedOnPrecision True if stopped on precision control e HasNewBestSolution New value of objective for optimizations was this a new best solution AfterlterationEvent Private Sub PortfolioOptRuntime_AfterIteration
213. hod as listed in Table 77 cbBftOutputLocation Integer 12 Used with va1ue1 to specify an output location in a new workbook cbBftOutputFormat Integer 13 Used with Valued to specify whether output is formatted If set to True it is formatted cbBftOutputCorrelationMatrix Integer 14 Used with va1ue1 to specify whether to output a matrix of correlations between the data series If set to True a matrix is produced cbBftOutputCorrelation Integer 15 Used with va1ue1 to specify whether to correlate assumptions cbBftLinkToCorrelationMatrix Integer 16 Used with va1ue1 to specify whether to link to the matrix of correlations between the data series assuming cbBftOutputCorrelationMatrix 14 is set to True If set to True creates a link to the matrix cbBftOutputGoodnessOfFitRepo rt Integer 17 Used with Value to specify whether to output a goodness of fit report If set to True a report is produced Value2 can be used to supply a sheetname as a string cbBftOutputAssumReport Integer 18 Used with va1ue1 to specify whether to output an assumptions report If set to True a report is produced Value2 can be used to supply a sheetname as a string cbBftOutputAssumFullStatistics Integer 19 Used with va1ue1 to specify whether to include full statistics in assumptions reports If set to True full statistics and percentiles deciles are
214. i21 ve e ax a A E eR 113 CB DefnePoreND eocivsirinsa airis 113 CB DefineForeND Example TET I gs iw bw dud 114 GB Depnis Por ND Related Calle arado RA Au RA EEKdu RES 114 CB DeleteChart asirirorarinda Sd AA ind 115 CB DeleteChart Example M or ae ad 4 419 CB DUE Chart DEUS LOL og d dec de d do une e EE ob RU dunk re AD eA nk ee oS bes A ees 115 CREMA Petals ciar AA 116 CB EnumAssum Related Calls das bas ees ates bas 254 er 116 CEE arar EEN NT A E T tr CB EnumChart Example n CPP 117 CB EnumChart Related Calls id ee i34 ad 118 RPO UE qudiwede R3 iT JH E E de b ed go desee ER CBRageuondanion Beagle coooseresaqueseoStabewaxexdverce va de 119 CB EmumCorrelation Example 2 sarrrcariialrr a usus 119 CD EnumCorrelation Related CIN uiua tek EE RR ERR RR RR RC d os 120 Contents vii viii Contents CB EnumDecVar ae T NUM m PE EINEN m TER s 120 L D EngmDecV ar Exaile 2 3 4 cquo RI HERRERA CHE Sp EX URP TR E ed EE eas 120 Blame a Related Cul ouaesdaeseqeseet bad beg eerie AA 121 CB EntmPote s auo S M EA 121 CB Enni ore Explain 121 Ch Enmitare Related Calls A 122 A AA 122 CB ExtractData Example ades sy 122 PAR DET ssa Ard RE Ra codon RACE ERE AIRE eA Eq A dr 123 LABRA Loud qaasbadamaadeedugaasdamdAq a
215. ibutes for a decision variable CB GetExcel2007ForegroundMode This function is used in Excel 2007 to retrieve the current setting for the Normal Speed preference Bring Excel 2007 to the foreground while running Normal speed simulations faster When set to True that preference lets simulations run at optimal speed when using Normal speed in Excel 2007 Table 112 CB GetExcel2007ForegroundMode Returned Data Type Returned Value Returned Data Type The current foreground mode Run Preferences setting for Normal speed in Excel 2007 boolean CB GetExcel2007ForegroundMode Example This example returns the current setting True or False for the preference Bring Excel 2007 to the foreground while running Normal speed simulations faster in the Normal Speed options dialog accessed manually by choosing Normal Speed on the Speed tab of the Run Preferences dialog and then clicking the Options button When set to False simulations in Excel 2007 might run more slowly than if the preference were set to True the default CB GetExcel2007ForegroundMode CB GetExcel2007ForegroundMode Related Calls Name Description CB SetExcel200 7ForegroundMode Sets the Run Preferences foreground mode setting for Excel 2007 in Normal speed CB GetFitParm This function returns the value of the specified distribution parameter for the last CB Fit 160 Crystal Ball Macro Calls Table 113 CB GetFitParm Returned Data Type R
216. ified number of iterations CB ResetND This subroutine resets the current simulation without prompting you to confirm the reset It automatically closes all forecast windows the trend chart the overlay chart and the sensitivity chart then it clears results from the previous simulation This is very useful to use before calls to subroutines and functions that require that a simulation be reset such as CB Freeze You can also call this subroutine to make sure that simulations start at Trial 1 For users to confirm the reset use CB Reset because it includes a prompt before it runs You do not have to run a simulation before you call this subroutine However it is convenient to run to ensure that no prior simulation results are around Note If you run a simulation using the CB Simulation subroutine without resetting Crystal Ballruns additional trials and adds the results to the existing results This is different from the user interface command which tells you it has reached the maximum number of trials and requires you to reset the simulation CB ResetND Example This example clears any simulation data and closes all forecast windows and charts without prompting to confirm the closures CB ResetND CB ResetND Related Calls Name Description CB Reset Resets a simulation after prompting 192 Crystal Ball Macro Calls Name Description CB Simulation Runs a simulation for specified number of iterations
217. ility simulation loop to 250 trials CB TwoDSimulationND cbTwoDInnerSimTrials 250 Set the forecast display to show only charts for the target forecast CB TwoDSimulationND cbTwoDForeOption cbTwoDShowTargetFore Set the report options to include forecast statistics and custom percentiles CB TwoDSimulationND cbTwoDOutputOption cbTwoDshowForeStat True CB TwoDSimulationND cbTwoDOutputOption cbTwoDshowPercentiles True CB TwoDSimulationND cbTwoDPercent cbTwoDPercentCustom F17 H17 Set the max number of uncertainty simulations to display in output to 75 CB TwoDSimulationND cbTwoDMSDOption 75 Run the 2D Simulation tool CB Two2SimulationND cbTwoDRun CB TwoDSimulationND Example 2 This example runs the 2D Simulation tool using default preferences or settings from a previous run in the current Microsoft Excel session CB ResetND Run the 2D Simulation tool CB TwoDSimulationND cbTwoDRun CB TwoDSimulationND Related Calls Name Description CB TwoDSimulation Launches the 2D Simulation tool CB GetTwoDSimulationOption Returns current settings for the 2D Simulation tool 240 Crystal Ball Macro Calls CB WorksheetProtection Crystal Ball cannot run a simulation ifa cell with Crystal Ball data is located in a write protected worksheet This subroutine is used to supply Crystal Ball with a worksheet password After that Crystal B
218. imulation must be reset Table 166 CB SetDecVar Parameters Parameter VBA Data Type Value Description DecVarReference Variant In a macro Range B3 Points to the decision variable cell with the data to change Index Integer See Table 167 Works with Value to set decision variable attributes Value Variant See Table 168 Changes decision variable attributes specified with Index Table 167 following describes the Index parameter Table 167 CB SetDecVar Index Parameter Values Required Integer Named Constant Value Index Value Description cbDecName 1 Changes the decision variable name according to Value cbDecMin 2 Changes the minimum lower bound according to Value cbDecMax 3 Changes the maximum upper bound according to Value cbDecType 4 Changes the decision variable type according to Value cbDecStep 5 Changes the step size for discrete decision variables depending on Value cbDecFrozen 6 Freezes the selected decision variable depending on Value 216 Crystal Ball Macro Calls Named Constant Value Index Value Description cbDecCustomData 7 Supplies a list of possible values for cbDecType Custom 4 Decimals can be used Table 168 following describes the Value parameter Table 168 CB SetDecVar Value Parameter Values Required Variant Used With Specified Values of Index Value Description For Index 1 cbDecName String Decision va
219. inomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use boolean True or False Indicates if the lock value should be used or not if set to True the lock value is used ParameterIndex Optional Integer See Table 53 to determine index values for target parameters The index of the distribution parameter to lock taken from Table 53 Value Double A positive real number The actual value to be used for the specified parameter Cell references cannot be used here To clear the locked value pass the constant cbParmUndefined Locked values are stored as if you had set them using Crystal Ball dialogs They do not need to be called before every CB Fit call CB LockFitParm 181 CB LockFitParm Example The following macro statements define a variable named Result lock the Location parameter of the gamma distribution clear any previous values from the Shape parameter of the gamma distribution run the fit and return results Notice that CB SetFitRange is used before CBLockFitParm Dim Result as Double Define a range of data for fitting CB SetFitRange A1 A30 Lock the Location of Gamma to 0 CB LockFitParm cbDfaGamma True 1 0 Clear any locked values for the Shape of Gamma CB LockFitParm cbDfaGamma True 3 cbParmUndefined Run the fit and return the result Result CB Fit cbDfaGamma cbFitAndersonDarling False CB
220. ion before you call this function or it returns 0 Note Reversing the percentiles using the cbRunReversePercentile constant does not affect the output of this function For more information see CB RunPrefsND on page 195 Table 121 CB GetForePercent Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the forecast cell for which you want the In a worksheet B3 percentile value Percent Double A number between O and Specifies the percentile for 100 which you want the forecast value CB GetForePercent Example 1 This example runs a simulation of 1000 trials and then puts the values for every fifth percentile into an array called Percents In a macro you can enter CB Simulation 1000 Dim Percents 19 As Double For i 1 To 19 Percents i CB GetForePercent Range C9 i 5 Next i 166 Crystal Ball Macro Calls CB GetForePercent Example 2 This example before a simulation displays 0 in the cell After a simulation it displays the forecast value at the 15th percentile of the forecast in B7 In a worksheet cell you can enter CB GetForePercentFN B7 15 CB GetForePercent Related Calls Name CB GetCertainty Description Returns the certainty level of achieving a forecast value at or below a specific threshold CB EnumFore Enumerates forecast cells for all open workbooks CB GetAssumPercent Returns percentiles
221. ion will only run if all system requirements are met including the availability of Microsoft NET Framework 2 0 3 0 or 3 5 If users have another version of the Microsoft NET Framework they might get an error when starting Crystal Ball Runtime You can either instruct them to run the Crystal Ball Application Manager and check the Microsoft NET Framework 2 0 3 0 or 3 5 checkbox or you can create or update an excel exe config file to ensure Crystal Ball runs against Microsoft NET Framework 2 0 3 0 or 3 5 To create or update excel exe config run the following script after the installation script AddInManager ConfigExcelForDotNet This script should be adjusted to run the Crystal Ball AddInManager from the Bin folder beneath the main Crystal Ball installation folder by default C Program FilesNOracle Crystal Ball Bin The resulting file excel exe config appears in C Program Files Microsoft Office Office where Office indicates the default version of Microsoft Office including Microsoft Excel that Crystal Ball opens when it starts If excel exe config already exists the information relevant to Crystal Ball is appended to it or updated as appropriate The new information in excel exe config indicates that Crystal Ball should use Microsoft NET Framework 2 0 3 0 or 3 5 Licensing Script A major part of Crystal Ball Runtime licensing is entering a license serial number so those who receive Crystal Ball Runtime appli
222. ions according to Valuel Note This constant only applies in Normal and Demo speeds it does not apply in Extreme speed cbRunHideForecasts 28 Sets whether to suppress forecast and assumption windows during simulations as well as overlay trend and sensitivity charts according to Valuel cbRunMode 29 Sets whether to run in Extreme Normal or Demo speed according to Value1 note that Extreme speed requires an Crystal Ball Decision Optimizer license cbRunRandomSeed 31 Specifies the initial random seed value according to Valuel cbRunPrecisionControl 40 Sets whether to stop a simulation when the forecast precision reaches a set confidence level only takes effect after a reset cbRunPrecisionConfidence 46 Sets the confidence level for precision control to va1ue1 cbRunReversePercentiles 47 Changes the interpretation of percentiles according to va1ue1 cbRunFormatPercentiles 48 Indicates how to format percentiles according to Valuel cbRunSaveAssumptionValues 196 Crystal Ball Macro Calls 49 Indicates whether to store assumption values for later analysis Named Constant Value Index Value Description such as sensitivity analysis according to Valuel cbRunLeaveOpenOnReset 50 Sets whether to leave the Crystal Ball Control Panel open when a simulation is reset according to Valuel cbRunUserMacros 51 Specifies whe
223. is call is used in a model that was created in an earlier version of Crystal Ball the third parameter has a value of 0 The following table lists the values for Parm1 Parm2 Parm3 and Parm4 for each DistType constant For more information about these parameter values see the description of each distribution type in Appendix A of the current Oracle Crystal Ball User s Guide The current Oracle Crystal Ball Statistical Guide lists defaults for each parameter value 104 Crystal Ball Macro Calls Table 53 CB DefineAssumND Parameter Values and Descriptions DistType Parameter Named Constant Value C continuous D DistType Parameter Index Parm4 Description discrete Value Parm1 Description Parm2 Description Parm3 Description Optional cbDfaNormal C 0 mean value standard deviation n a n a value cbDfaTriangular C 1 minimum value likeliest value maximum value n a cbDfaPoisson D 2 rate value between n a n a n a 0 and 1000 cbDfaBinomial D 3 probability trials a whole n a n a between 0 and 1 number greater than O and less than 1000 cbDfaLogNormal C 4 mean value standard deviation location n a value cbDfaUniform C 5 minimum value maximum value n a n a cbDfaExponential 6 rate greaterthan O n a n a n a C cbDfaGeometric D 7 probability n a n a n a between 0 and 1 cbDfaWeibull C 8 location scale greater than shape greaterthan n a 0 0 05 cbDfaBeta
224. is example unchecks or clears the preference Bring Excel 2007 to the foreground while running Normal speed simulations faster in the Normal Speed options dialog accessed manually by choosing Normal Speed on the Speed tab of the Run Preferences dialog and then clicking the Options button When set to False simulations in Excel 2007 might run more slowly than if the preference were set to True the default CB SetExcel2007ForegroundMode False 218 Crystal Ball Macro Calls CB SetExcel2007ForegroundMode Related Call CB GetExcel2007ForegroundMode Description Returns the current Run Preferences foreground mode setting for Excel 2007 in Normal speed CB SetFitRange This function is used with CB Fit CB Fit on page 131 to specify a worksheet range that contains the set of data to fit to a distribution In a subroutine this call takes the form CB SetFitRange Range A1 A15 Table 170 CB SetFitRange Parameter Parameter RangeRef VBA Data Type Variant Value In a macro Range B3 Description Points to the cell range with the data to fit to a distribution CB SetFitRange Examples See the examples for CB Fit on page 131 CB SetFitRange Related Call Name Description CB Fit Fits a specific probability distribution to a range of data and returns information about the fit CB SetFore This function changes forecast attributes without redefining the fore
225. isResetSessionVa riable Integer 17 Resets all session variables related to the CB DataAnalysisND Developer Kit call including the input data series and the LSL USL and Target capability values Table 44 CB DataAnalysisND Value Parameter Optional Variant Related Value For Index 2 cbDataAnalysisSelectDa ta Named Constant Value A cell reference with format Range A1 C300 or A1 C300 VBA Data Type Variant Index Value n a Description Specifies the numeric portion of the data to be imported CB DataAnalysisND 93 Related Value Named Constant Value VBA Data Type Index Value Description For Index 3 cbDataAnalysisDatalnRo Integer 1 Indicates that data cells cbDataAnalysisDataOrie ws are in rows ntation For Index 3 cbDataAnalysisDatalnCo Integer 2 Indicates that data cells cbDataAnalysisDataOrie lumns are in columns ntation For Index 4 True or False boolean n a Indicates whether to cbDataAnalysisSelectHe include column header aders text in the selection True include the top row of text For Index 5 True or False boolean n a Indicates whether to cbDataAnalysisSelectLa include row label text in bels the selection True include the first column of text For Index 6 A cell reference with Variant n a Sets the selected range cbDataAnalysisSelectLS format Range A1 C300 of values as forecast L or A1
226. isionTable 156 CB AboutBox 42 CB AlertOnArgumentError 42 CB AlertOnMacroResultError 43 CB AlertOnObsolete 43 CB AssumPrefsND 44 CB AutoDownshift 45 249 CB BatchFit 46 CB BatchFitND 46 CB Bootstrap 55 CB BootstrapND 56 CB CBLoaded 59 CB CellPrefs 60 CB CellPrefsND 61 249 CB ChartPrefs 63 CB ChartPrefsND 64 250 CB CheckData 67 250 CB CheckDataND 68 CB ClearData 69 250 CB ClearDataND 70 250 CB CloseAllCharts 70 CB CloseChart 71 CB CloseFore 72 250 CB CloseSensitiv 72 250 CB CloseTrend 73 CB CopyData 74 251 CB CopyDataND 74 251 CB CopyScatter 75 CB CopySensitiv 76 CB CopyTrend 76 CB CorrelateND 77 251 Index 293 A B C D E F CB CreateChart 79 CB CreateRpt 80 251 CB CreateRptND 80 251 CB DataAnalysis 91 CB DataAnalysisND 91 CB DecisionTable 96 CB DecisionTableND 96 CB DefineAltParms 99 252 CB DefineAssum 102 253 CB DefineAssumND 103 253 CB DefineDecVar 108 253 254 CB DefineDecVarND 109 253 254 CB DefineFore 112 CB DefineForeND 113 254 CB DeleteChart 115 CB EnumAssum 115 254 CB EnumChart 117 CB EnumCorrelation 118 CB EnumDecVar 120 254 CB EnumFore 121 254 CB ExtractData 122 CB ExtractDataND 123 254 CB Fit 131 255 CB FormatPrefs 135 CB FormatPrefsND 135 CB Freeze 138 256 CB FreezeND 138 256 CB GetAssum 140 256 CB GetAssumEN 140 CB GetAssumPercent 143 256 CB GetAssumPercentFN 143 CB GetBatchFitOption 144 CB GetCBAutoLoad 15
227. istics section in the report following a Predictor run the Predictor statistics information False does not 84 Crystal Ball Macro Calls Named Constant Value Index Value Description Value1 Optional Value2 Optional cbRptPredictorAutocorrel 47 Includes the Predictor boolean True includes n a ations Autocorrelations section the Predictor in the report following a autocorrelations Predictor run information False does not cbRptPredictorForecast 48 Includes the Predictor boolean True includes n a Forecasts section in the the Predictor forecasts report following a information False does Predictor run not cbRptPredictorConfidenc 49 Includes the Predictor boolean True includes n a elntervals Confidence Intervals the Predictor confidence section in the report intervals information following a Predictor run False does not cbRptPredictorMethods 50 Indicates which Predictor Integer See Table 41 n a Methods to include in the below report Note The following constants have been removed since Crystal Ball 2000 5 5 5 cbRptForeFrequencies Index 8 obsolete coRptDecVar Index 15 included in CB 7 1 and later for compatibility users should migrate to using cbRptChooseDecVar instead cbRptScatterChart 38 and similar constants such as cbRptOverlayChart 14 include all open charts of the selected type as stated in their descriptions These constants override
228. isting worksheet the report in a new page of the existing workbook False creates the report in a new workbook cbRptSummary 17 Specifies which boolean True includes Integer See Table 36 summary information to the parameter specified include in the report in Value2 False does not cbRptChooseDecVar 18 Clears adds and sets Integer See Table 37 n a the list of decision variables to include in the report cbRptDecVarBounds 19 Includes the bounds for boolean True includes n a each included decision the bounds False does variable not cbRptDecVarlype 20 Includes the type for boolean True includes n a each included decision the type False does not variable cbRptAssumStatistics 21 Includes the statistics boolean True includes n a table for each included the statistics False does assumption not cbRptAssumPercentiles 22 Includes the percentile boolean True includes Integer Same as that data for each included percentile data False for cbRptFore assumption does not Percentiles See Table 32 below cbRptAssumCorr 23 Includes the correlations boolean True includes n a for each included the correlations False assumption does not cbRptOverlayCharts 24 Includes the distribution boolean True includes Integer 1 to 200 graph for each included the charts False does defines the percent scale overlay chart not of the charts cbRptTrendCharts 25 Includes the graph for boolean True includes Integer 1 t
229. izGrids Boolean False the horizontal grid lines Note See the Oracle Crystal Ball User s Guide for more information on how to customize assumption and forecast charts CB ChartPrefsND Example This example selects a forecast cell and then changes its forecast chart to show a mean line Range B7 Select CB ChartPrefsND cbChtMeanLine True CB ChartPrefsND Related Calls Name Description CB ChartPrefs Displays the Chart Preferences dialog CB CheckData This subroutine scans Crystal Ball data on open worksheets checks the assumptions for validity and initializes internal variables for the start of an enumeration If errors occur appropriate dialogs appear and you are prompted to correct them You should call CB CheckData or CB CheckDataND each time you start a new enumeration use a CB Get call that relies on cell references that might have changed and each time you delete or add data You should use CB CheckData or CB CheckDataND before using calls that extract data or create reports CB CheckData Example This example runs a simulation of 500 trials initializes all the internal variables for the following enumeration and then enumerates all the forecasts opening each forecast chart Dim s As String Dim r As Range CB Simulation 500 CB CheckData s CB EnumFore While s lt gt CB CheckData 67 Set r Range s CB OpenFore s CB EnumFore t t 1 Wend CB CheckD at
230. ks associated with the use of such content If you choose to purchase any products or services from a third party the relationship is directly between you and the third party Oracle is not responsible for a the quality of third party products or services or b fulfilling any of the terms of the agreement with the third party including delivery of products or services and warranty obligations related to purchased products or services Oracle is not responsible for any loss or damage of any sort that you may incur from dealing with any third party Contents Chapter 1 Welcome 25 420i 4006 cease ase eR ea AAA RAR ERASER ERE EO RRR 19 About the Oracle Crystal Ball Developer Kit 2 2 scc03s ses eeee rm 19 Who Should Use the Crystal Ball Developer Kit oooooooooocoooomomo o ee 20 What You WillNeed osea ced quer RAS REA A OE ee Hoe ARANA 20 How The Mania Organized epa AAA 20 INES UI o ARA A AR ARA AAA AS AAA 21 Tell Support aul Mere sararerar n arrastrar aa 21 Chapter 2 Crystal Ball Developer Kit Overview oo oooocoooorooo IBI 23 ap pP 23 How to Use the Crystal Ball Developer Kit ccoo occiso ERR RR EE 24 Calling Crystal Ball From Visual Basic For Applications VBA Programs 24 Calling Crystal Ball From an External Visual Basic VB PrograM 25 COREA Exe POE asap pode Re EO do ORI deb Pole baba on Re oot 26 Using Developer Kit Macro Calls i
231. l report cbRptAssumption 2 Report format is the predefined assumption report cbRptForecasts 3 Report format is the predefined forecast report cbRptDecVars 4 Report format is the predefined decision variable report cbRptindex 5 Report format is the predefined index report cbRptCustom 6 Report format is set through various CB CreateRptND code statements cbRptOptimizer 7 Report format is the predefined OptQuest report available following an OptQuest optimization run cbRptPredictor 8 Report format is the predefined Predictor report available following a Predictor forecasting run With Index set to cbRptSection you can use the following constants as the Value2 parameter to specify the order of report sections see Table 40 Table 40 For Index cbRptSection Value2 Values Optional Integer Named Constant Value Index Value Description cbRptSectSummary 1 Includes the summary section cbRptSectOverlay 2 Includes the overlay chart section cbRptSectTrend 3 Includes the trend chart section cbRptSectSensitivity 4 Includes the sensitivity chart section cbRptSectScatter 5 Includes the scatter chart section cbRptSectForecasts 6 Includes the forecasts section cbRptSectAssumptions 7 Includes the assumptions section cbRptSectDecVars 8 Includes the decision variables section 88 Crystal Ball Macro Calls Named Constant Value Index Value Description cbRptSectOptimizerResults 9 Includes the
232. l Ball system requirements For more information see System Requirements and NET on page 265 Installation Script The application setup script should include this command setup exe s v qn norestart lv c install log where e setup exe is the executable for the appropriateCrystal Ball installer If you downloaded your version of Crystal Ball from the Web the filename can include the version number such as cb111 exe and that name should appear in the script e s silent mode e v pass arguments to msiexec e qn do not display the UI e norestart do not restart e lv lt logfile gt verbose output which writes the file c install log To add a progress bar insert passive as an argument between gn and norestart Note Using the silent install on Windows Vista is similar however you have to right click and choose Run As Administrator when opening the Vista Command Prompt 264 Crystal Ball Runtime Because the arguments passed in with the v switch are arguments to the Windows Installer msi you can use the following to perform a silent install with the Windows Installer if you have extracted Crystal Ball msi from setup exe msiexec i Crystal Ball msi qn norestart lv c install log System Requirements and NET For current system requirements for running Crystal Ball see the current Oracle Crystal Ball Installation and Licensing Guide The installation script described in the previous sect
233. ld Use the Crystal Ball Developer Kit The Crystal Ball Developer Kit is appropriate for advanced users who want to automate repetitive spreadsheet analysis This manual assumes that readers are familiar with Visual Basic for Applications and Crystal Ball What You Will Need Crystal Ball runs on several versions of Microsoft Windows and Microsoft Excel For a complete list of required hardware and software see the Oracle Crystal Ball Installation and Licensing Guide How This Manual is Organized 20 Welcome This manual contains descriptions of the Crystal Ball Developer Kit macro calls It also discusses the COM Developer Kit for OptQuest Predictor and Oracle Hyperion Smart View for Office Fusion Edition integration Each macro description includes a list of parameters and an example of the use of the relevant calls The manual includes the following additional chapters e Chapter 2 Crystal Ball Developer Kit Overview Describes how to use the Crystal Ball Developer Kit and contains an alphabetical list of all Crystal Ball Developer Kit calls with summaries plus tables of related calls e Chapter 3 Crystal Ball Macro Calls Includes descriptions of all Crystal Ball Developer Kit calls in alphabetical order with examples e Chapter 4 Changes from Previous Versions Information about changes since previous releases of Crystal Ball e Chapter 5 Crystal Ball Runtime Information about creating applicatio
234. le value cells or blank cells Forecasts may be pasted only into value or formula cells If assumptions or decision variables are pasted into a range that is totally blank any underlying Excel values are pasted along with the Crystal Ball data Ifthe range selected for pasting contains more value or formula cells than are selected for copying the cells will repeat For example if the CopyData range includes two assumptions and the PasteData range includes three value cells the first and second assumptions are pasted and then the first assumption is repeated Note Before calling this subroutine copy Crystal Ball data using CB CopyData or CB CopyDataND CB PasteData Example 1 This example copies the Crystal Ball data from cell C1 and pastes it into cell D1 Range C1 Select CB CopyData Range D1 Select CB PasteData 190 Crystal Ball Macro Calls CB PasteData Example 2 This example copies the assumption data from cells B5 B6 and B7 and then pastes it into the corresponding cells D1 D2 and D3 provided those cells contain values and not formulas Range B5 B7 Select In the above command B5 B6 and B7 are all assumptions CB CopyData Range D1 D3 Select CB PasteData CB PasteData Example 3 This example copies the Crystal Ball data from cell B5 and pastes it three times into cells D1 D2 and D3 Range B5 Select CB CopyData Range D1 D3 Select CB PasteData
235. lean parameter added for Crystal Ball 7 0 e Starting with Crystal Ball 11 1 1 0 00 the optional Asynchronous parameter is obsolete For placeholder purposes this parameter remains in the code and has been renamed to Obsolete Asynchronous If any other optional parameters are used a double set of commas should appear between Iterations and the other optional parameters to show that there is another parameter with no value between them CB StartMultiSimul Has three optional parameters Rescan SaveAssumValues and MultiAutoDownshift The last two were added in Crystal Ball 7 2 1 260 Changes from Previous Versions CB TrendPrefsND e cbIrdForeTitleAxis 3 is now obsolete e cbTypCertCenteredOnMean 2 is now obsolete e cbTypCertCenteredOnMedian 4 is added e Certainty band values for Index constant cbTrdCertaintyBands no longer need to be divisible by 5 Other Changes These are general changes that do not apply to a particular call Charts Module The Crystal Ball 2000 5 5 5 Developer Kit included a Charts module in the cb xla code file Because of the way charts are created in later versions of Crystal Ball that module is no longer included in the Developer Kit Other Changes 261 262 Changes from Previous Versions Crystal Ball Runtime In This Chapter MOI A creas Std napa ag te err 263 ACUESTA OREA 263 Delivering Crystal Ball Runtime APD ICAO nanesi A ee ee ee is 264 Installing Crystal Ball
236. learing CB data 69 70 closing CB forecasts 72 charts 70 71 72 73 code development OptQuest 274 coding optimization 277 constraints and macros 283 consulting 21 contact information 21 copying CB data 74 charts 75 76 correlating assumptions 77 correlations enumerating 118 correlations getting for two assumptions 153 creating an Excel add in 26 assumptions 102 103 CB forecasts 112 113 charts 79 decision variables 108 109 reports 80 Crystal Ball starting manually 21 Crystal Ball Developer Kit 278 Crystal Ball versions 176 custom applications 200 custom distributions 107 customizing scatter charts 202 203 sensitivity charts 210 trend charts 231 232 Index 295 A B C D E F D data clearing CB 69 70 copying CB 74 extracting CB 122 123 forecasts 165 initializing CB 67 68 pasting CB 190 Data Analysis tool 91 154 data versions 178 Decision Table tool 96 decision variables defining 108 109 enumerating 120 retrieving information 158 selecting 209 setting attributes 216 DecisionTable tool 156 default values 26 defining assumptions 102 103 CB forecasts 112 113 custom assumptions creating custom assumptions 107 decision variables 108 109 definitions 21 deleting charts 115 Developer Kit how to use 24 welcome to 19 what s new 21 developer kit help 274 developer kit namespace Predictor 287 developer kit structure Predictor 286 developer kit Opt
237. lled user use the CB RuntimeMode call to hide the Crystal Ball user interface Then you can substitute your own controls created with Visual Basic or VBA to activate Crystal Ball features using Crystal Ball Developer Kit calls Crystal Ball Developer Kit Overview Your application can use any of the Crystal Ball features accessible through the Developer Kit You can also include Predictor time series analyses in your applications and users can run simulations in Extreme speed if it is available to them with Crystal Ball Decision Optimizer For details see Chapter 5 Crystal Ball Runtime Alphabetic List of Crystal Ball Macro Calls Note Full descriptions are listed alphabetically in Chapter 3 in the indicated sections Table 1 Alphabetic List of Crystal Ball Macro Calls Name CB AboutBox on page 42 Description Displays information about Crystal Ball CB AlertOnArgumentError on page 42 Displays a message when an argument error occurs CB AlertOnMacroResultError on page 43 Displays a message when an execution error occurs CB AlertOnObsolete on page 43 Displays a message when an obsolete call or constant is used CB AssumPrefsND on page 44 Sets attributes of Crystal Ball assumptions CB AutoDownshift on page 45 In Crystal Ball Decision Optimizer determines whether to automatically downshift to Normal speed or fail when a model is incompatible with Extreme speed CB
238. lues are used Table 83 CB GetAssum Returned Data Type Returned Value Returned Data Type Some attribute or parameter for the assumption Variant Table 84 CB GetAssum Parameters Parameter VBA Data Type Value Description AssumReference Variant In a macro Range B3 Points to the desired mption cell In a worksheet B3 assumpuon ce Index Integer See Table 85 Retrieves information for a specific assumption cell using constant and index values listed in Table 85 ParmNumber Optional Variant 1 2 3 4 Specifies the target distribution parameter for Index equal to either cbAsmParmName or cbAsmParmValue Note For hypergeometric distributions whether the distribution was created in pre 7 0 releases with the Probability parameter or in later versions of Crystal Ball with the Success parameter index 17 for coDfaHypergeometricSuccess is always returned and the first parameter and value are Success not Probability Table 85 following shows named constant and index values for the Index parameter Note Index values cbAsmNumParms cbAsmParmName cbAsmParmValue cbAsmLowCutOff and cbAsmHighCutOff are not supported for custom distributions Table 85 CB GetAssum Index Parameter Values Required Integer Named Constant Value Index Value Description cbAsmName 1 Returns the assumption name cbAsmbDistType 2 Returns the index value of the distribution type See Table 53 cbAsmNumPar
239. m three namespaces appear in the navigation pane Figure 1 These namespaces are only used in C code not Visual Basic VBA code However if you are using VBA they indicate which classes are used for OptQuest automation Optimization and which are used for Predictor Predictor When writing VBA code you omit Optimization or Predictor as shown in the code examples included in this Developer s Guide 214 Using the OptQuest Developer Kit Figure 1 CB Com Devkit chm with Three C Namespaces E CB Com Devkit D Br Hide Locate Bach Home Print Options Contents index Search ElCollapse All gt Language Filter C CB Com Devkit Decisioneering CB CBCOMDevKit Namespace E e Decisioneering CB CBCOMDevKit Optimization Namespace ic o Decisioneering CB CBCOMDevKit Predictor Namespace Crystal Ball COM and NET Development Kit Namespace Types alltypes ctasses Name Description a MRWrapper MR Command wrapper Use in using statements to insure MR status tracked and set into command processor for all COM visible calls for DevKit integration The Index and Search tabs are helpful for locating information about a specific class For example if you click the Search tab type Constraint and then click List Topics you can select one of the listed topics to display it in the right pane See Figure 2 following for an example of the Constraint Properties topic for OptQuest You can also revie
240. m OotVar Equation Constraint equation Exclude Is var excluded Inherited from OptVar El Optimization State Enumeration OptimizationStatistics Get the statistics for this Optimization Variable E 5 Statistics are based upon the current OptRuntime E OptMoreLessCondition Enumeration bilis Elba E OptObjective Type Enumeration Inherited from OptVar E OptOptimization Type Enumeration m OptOptions Class a OptRunForType Enumeration See Also E OptRuntime Class 8 OptRuntime AfterSimulationEvent Handler Delegate Constraint E OptRuntime EficientFrontierEventHandler Delegate Decisioneering CB CBCOMDevkKit Optimization Namespace E OptRuntime OptEventHandler Delegate Hj pH y Heg Ey CB Com Devkit chm is generated from actual OptQuest Developer Kit code and has a development language filter to help you with your code The default is C You can change to Developing Optimization Code 275 Visual Basic or Visual Basic Usage for code snippet examples The topic in Figure 2 has two collapsible headings Properties and See Also Other topics such as Decision Class shown in Figure 3 have an additional Syntax heading The Syntax tabs are linked to the Language Filter menu at the top of the help window In Figure 3 the language filter is set to Visual Basic Usage That tab appears below the Syntax heading Since the Visual Basic Usage filter shows sample Visual Basic code a code snippet appears on the tab
241. macro runs at the beginning of the optimization when the Run button is first clicked or the Run command is given After that the Simulation and Iteration event macros take over and run as described until all requested trials and simulations have been run or a stopping point set in the Advanced Options dialog has been reached At that point the optimization is complete and the AfterOptimizationEvent macro runs Using Events in VBA To use these events in Excel VBA open the Excel Visual Basic Editor and open a code window for a workbook Begin by explicitly declaring the CBCOMDevKit OptRuntime class as a variable with events Private WithEvents PortfolioOptRuntime As CBCOMDevKit OptRuntime In this example the variable name PortfolioOptRuntime is declared as on OptRuntime class type Then declare other variables as required For more information see Coding an Optimization on page 277 Whenever you want to enter an event macro into your code go to the dropdown list in the upper left corner of the code window and choose the name of the variable assigned to OptRuntime Available events are listed in the upper right corner of the code window When you click one it is inserted into your code for that workbook as a private subroutine for example Private Sub PortfolioOptRuntime_AfterIterationEvent IterationsCompleted As Long End Sub 280 Using the OptQuest Developer Kit The subroutine takes the name of the variable assig
242. mand is given using the OptQuest Developer Kit BeforelterationEvent Optimization At the start of each iteration of an optimization just after the decision variable values for that iteration have been written to the workbook but before any nonlinear constraints have been evaluated by OptQuest BeforeSimulationEvent Simulation On each iteration of an optimization just before the simulation begins At this point nonlinear constraints have been evaluated by OptQuest User defined Event Macros for Optimizations 279 Event Type Runs AfterSimulationEvent Simulation On each iteration of an optimization just after the simulation completes Any extracted data values will have been written to the workbook as part of the simulation processing Forecast objective and requirement values have not yet been updated to OptQuest Note at this point any solution values for this iteration are not yet valid AfterlterationEvent Optimization After each iteration of an optimization The simulation is complete any extract data has been written to the workbook and objective and any requirement values have been updated to OptQuest Note at this point all solution values for this iteration are valid AfterOptimizationEvent Optimization After an optimization is complete EfficientFrontierEvent Optimization After each test point in an Efficient Frontier optimization is complete The BeforeOptimizationEvent
243. moved o cbPrecisionPerc 12 is renamed to cbForPrecisionPerc to correct a documentation error o cbPrecisionPercValue 13 is renamed to cbForPrecisionPercValue to correct a documentation error o cbForFilterGlobal 18 was obsolete in the Crystal Ball 7 1 version of the Developer Kit It is now valid and has been added back o cbForFrozen 19 cbForLSL 20 cbForUSL 21 and cbForTarget 22 are added CB GetForeStat New constants with index numbers 50 through 64 have been added to support Crystal Ball s process capability features In version 11 1 1 3 00 a new constant cbFstBaseCase 14 was added to return the base case initial value of a forecast cell CB GetRunPrefs The additional parameters listed in the Developer Kit documentation for Crystal Ball 2000 5 5 5 coRunStdError and cbRunBurstAmount are obsolete in this version of the Crystal Ball Developer Kit Changes to Existing Calls 257 CB GetVersion CB GetWorksheetVersion e Starting with version 11 1 1 0 00 two optional parameters ValueType and Index return the full or partial version ID or build number Full IDs or numbers are returned as strings and partial IDs or numbers are returned as an integer CB IsCBObject e The parameter SheetObj changes to AnObject its data type changes from Object to Variant CB OpenSensitiv e Achartcan now be explicitly selected via CB EnumChart and CB SelectChart before it can be opened CB OpenTrend e Ac
244. mple This example opens the Define Forecast dialog so you can define or redefine a forecast Range B5 Select CB DefineFore CB DefineFore Related Calls Name Description CB GetFore Retrieves information for a specific forecast cell CB SetFore Changes forecast attributes without redefining the forecast CB DefineForeND This subroutine defines or changes a forecast in the selected cell without using a dialog The selected cell must contain a simple value an expression or a cell reference otherwise CB MacroResult returns cbErrNoForecastInCell Note Before calling this subroutine select a cell Table 56 CB DefineForeND Parameters Parameter FName Optional VBA Data Type Variant Value Title surrounded by quotes Description Specifies how Crystal Ball identifies the forecast If you do not specify a name Crystal Ball uses the first of either the cell s range name text from the cell to the left text from the cell above the cell s coordinates Units Optional Variant Words surrounded by quotes Specifies the units label of the forecast chart DisplayAuto Optional Variant True or False True sets the forecast window to open automatically according to the DisplayWhileRunning setting False requires you to open the forecast chart manually through the Analyze then Forecast Charts command The default is True CB DefineForeND 113
245. ms 3 Returns the number of distribution parameters cbAsmParmName 4 Returns the name of the distribution parameter indexed by ParmNumber CB GetAssum 141 Named Constant Value Index Value Description cbAsmParmValue 5 Returns the value of the distribution parameter indexed by ParmNumber cbAsmLowCutOff 6 Returns the value of the lower truncation point cbAsmHighCutOff T Returns the value of the higher truncation point cbAsmDistFlag 8 Returns the extreme value distribution flag O cbFlgMinimum 1 cbFlgMaximum cbAsmFrozen 10 Returns True if the assumption is frozen and False if it is not frozen cbAsmlsSequential 11 Returns True if the assumption uses sequential sampling and False if it does not CB GetAssum Example 1 This example puts information for the first three Index constants for the assumption in cell B3 into cells F1 through F3 In a macro you can enter For i 1 TO 3 CB CheckData Worksheets sheet3 Range F1 Offset 1 Value _ CB GetAssum Worksheets Sheet1 Range B3 i Next i CB GetAssum Example 2 This example enters the name of the assumption in cell B3 into the cell that holds this formula In a worksheet cell you can enter CB GetAssumFN B3 1 CB GetAssum Related Calls Name Description CB DefineAssumND Defines or changes assumptions in selected cells without a dialog CB EnumAssum Enumerates assumption cells for open worksheets
246. n 3 cbChfChosen 4 cbChfAdd 5 cbChfClearList cbExtPercentiles See Table 69 Specifies which percentiles to extract Used with these value parameter values described in Table 69 1 cbPctQuartiles 2 cbPctQuintiles 3 cbPctDeciles 4 cbPctlcosatiles 5 cbPctSet1 6 cbPctSet2 7 cbPctSet3 8 cbPctSet4 cbExtExistingSheet True or False True extracts data to a new worksheet called Data in the active workbook False extracts data to a new worksheet called Data in a new workbook cbExtChooseAsm See Table 70 Specifies which assumptions to include Used with these Value parameter values described in Table 70 1 cbChaAIl 2 cbChaChosen 3 cbChaAdd 4 cbChaClearList 5 cbChaOpen cbExtChartBins A value between 10 and 1000 Indicates how many bins value groups or intervals to include Note This value is independent of the Chart Preferences density setting 124 Crystal Ball Macro Calls Index Parameter Named Constant Value cbExtIncludeCellLoc Index Parameter Index Value 8 Value Parameter Values to Use True or False Description True includes cell location information False does not include cell location information cbExtIncludeLabels True or False True includes labels False does not include labels cbExtAutoFormat 10 True or False True applies formatting to the cells as appropriate False does not
247. n User defined Macros lees 26 A Note About Defaults and Write Protection leen 26 Putting Custom Applications into Runtime Mode lt lt e or m 26 Alphabetic List or Crystal Ball Macro Calls i244 kara a RR REG A X ER RARE Rn 27 Funcions For Use in Excel Mode siges cuyas EE Suet RS EROR x ERR RR ORA 32 Opening and Closing Crystal Ball corno RE E RAO ERR EO EE AR AY A 32 Setting Up and Kunming SOs 1 cosrrsidcas corre REOR RE REHOR RO de e 33 Controlling Crystal Ball Chart WIndows cs ure RAE EEGe s uYR dE Ra ERE 34 RCT 2219242923492 26245 DERRM E PAPECRE EPICURI iE ACE A PU pa 35 Handling Crystal Ball Resulis iue es RR RR x RE x RR Ex RE bas 35 Setting and Getting Preferentes cr dw Shh AAA NAAA 36 EU AA Bap doe ea oo d de gab Oneida do 37 canal mtr 37 Chapter 3 Crystal Ball Macro Calls ccooocoomcaci a cana ca rra aa a aS 39 Cri 42 A ni o AP 42 etica ae AS 42 Contents iii iv Contents CB AlertOnArgumentError md ads seni os 42 Co Agni cuc rar Example iua arque AREA AENA 43 CI Ale On agumantEror Related Calls 24 2425294Pa R Rd PE ERRPEREEdR Rd 43 CB AlertOnMacroResultError er eens Stes T EE gus TEE eer sre 43 CB AlertOnMacroResultError Example ciones rd deiss 43 CB AlertOnMacroResultError Related Calls e icaoircicra ira 43 CB AlertOnObsalete oxccorocar d IDA Edda ab ie d qo a radi 43 CB Ale
248. n for the assumption CB ResetND Range B5 Select CB DefineAssum CB DefineAssum Example 2 This example selects cell D5 previously defined as a uniform distribution assumption and then opens the Uniform Distribution dialog with the current parameter fields filled in You can change the parameters or select a different distribution by clicking Gallery CB ResetND Range D5 Select CB DefineAssum CB DefineAssum Related Calls Name Description CB CorrelateND Defines a correlation coefficient between two selected assumptions CB DefineAssumND Defines or modifies assumptions in selected cells without using a dialog CB GetAssum Retrieves information for a specific assumption cell CB SetAssum Modifies certain attributes for the assumption in a cell CB DefineAssumND This subroutine defines a new assumption or changes an existing assumption in the selected cell without using a dialog If a simulation runs before this subroutine is used the simulation must be reset before the assumption is defined Note Before calling this subroutine select a single cell CB DefineAssumND 103 Table 52 CB DefineAssumND Parameters Parameter DistType VBA Data Type Integer Value Integer value or named constant See Table 53 Description Specifies a distribution type for the assumption The number of parameters varies with the distribution type See the table on the next page for types an
249. naa tada pee uar in 256 CB GetFitParm eta ee ae as ones back eee TET ENS es ds is 297 RIOS soja a aa ai 257 A deg dr ep dar acd c qacq ades ee dag ud ciuubar quare 257 CBGetiunPEtebs porrer ta ira m qe pauadoa qua 257 CB GetVersion CB GetWorksheetVersion ess a Bed ure 258 o A A DER S VE da 258 LBIDDEHSEHOIDE diua pec pE Add Rp Tq da pd e pe dvds e ad 258 CB OpenTrend dm ee d T mL S B n T 258 e Dd aia Eoo EO pd HH oor eoo o p oar o ses 258 CR Run PrebND SA ooo hohe ieee ee ras 258 CE Sere teats cetee plated A A 259 CB SetAssum ib Seas A RS e PWGe 259 DEBEO rara da cia ME rada is 259 B SELPOBE jack ak iR o cA ORO pU ACE OR CR b GR OA Re AKER Re we a 260 CB SimResult ee ee ead E ee T dns aves 260 se A Ee eb de Odeon de Co oe T ee 260 CE Sue tA coloso rs o ri a is 260 CB TiendPrefsND esposos ire 261 se AAA ae ee em ea ee er re a 261 Contents xv Charts Module ET A er RT P V eae PT 261 Chapter 5 Crystal Ball Runtime 00 0 0 000000000 eR eee eee IRR es 263 Bid POE DOR a do EROR GRECE ER de MEE pde ORO GIRO re q OR e d 263 About Crystal Ba ROMME ses ese hk Raesq RAE AAA AAA seus 263 Runtime Example Workbook 10234044 02005d5400 050940060554 P A 263 Delivering Crystal Ball Runtime Applications abed piss bes eee diss 264 Installation Seript 4 usos A A 264 System Requirements and NET coo 265 Licensing Script
250. nal constants for parameters Valuel and Value2 are added to support the new Index constants They are listed in Table 36 through Table 40 Unlike in pre 7 0 versions the following statement needs to be added at the beginning of the Create Report code to create a custom report CB CreateRptND cbRptDefinedType coRptCustom Otherwise the type of report currently selected in the Create Report dialog by default the Full report is created For Index constants supported in Crystal Ball 2000 5 5 5 the following changes appear Changes to Existing Calls 251 o cbRptForePercentiles two new constants are added for Value2 described in Table 32 cbPctSet3 7 cbPctSet4 8 o cbRptChooseAssum a new constant is added for Valuel cbChaOpen 5 described in Table 34 o cbRptChartType the constant cbChtBW 0 is now obsolete and has been removed e To support the rewritten version of OptQuest added in version 11 1 1 0 00 o The following new Index constants are added coRptOptimizerSummary 39 cbRptOptimizerChart 40 coRptOptimizerBestSolution 41 cbRptOptimizerConstraints 42 coRptOptimizerDecVars 43 o A new report section type is available as Value2 for cbRptSection cbRptSectOptimizerResults 9 o Anew Value2 constant is available for cbRptDefinedType coRptOptimizer 7 o Amninth integer is available for coRptSectionOrder the cbRptSectOptimizerResults section is assigned number 9 e To support the rewritt
251. nalyze then Close All CB CloseChart Closes the selected chart of the given type CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB OpenFore This subroutine opens the forecast window for the selected cell The worksheet must be active a simulation run and a forecast cell selected for Crystal Ball to run this command CB OpenFore 187 CB OpenFore Example This example runs a simulation of 1000 trials activates the Model worksheet of the Futura with OptQuest xls workbook and selects cell C9 a forecast It then opens the forecast window associated with that cell CB Simulation 1000 Workbooks Futura with OptQuest xls Worksheets Model Activate Range C9 Select CB OpenFore CB OpenFore Related Calls Name Description CB CloseFore Closes the forecast window for the selected cell CB Simulation Runs a Crystal Ball simulation CB OpenSelection This subroutine is the equivalent of Analyze then Open Selected Cells It opens all charts defined for cells in the selected range Before calling this subroutine run a simulation CB OpenSelection Example This example runs a simulation of 5000 trials and then opens whatever charts are defined for cells C9 C10 C11 and C12 CB Simulation 5000 Range C9 C12 Select CB OpenSelection CB OpenSelection Related Calls Name Description
252. nd truncation values Table 161 following describes the Index parameter Table 161 CB SetAssum Index Parameter Values Required Integer Named Constant Value Index Value Description cbAsmName 1 Changes the assumption name according to Value cbAsmLowCutOff 6 Changes the lower truncation point according to Value cbAsmHighCutOff 7 Changes the higher truncation point according to Value Table 162 following describes the Value parameter CB SetAssum 213 Table 162 CB SetAssum Value Parameter Values Required Variant Used With Specified Values of Index Value Description For Index cbAsmName 1 String Assumption name in quotes Specifies the new assumption name For Index cbAsmLowCutOff 6 Any number Sets the new lower truncation point Double For Index cbAsmHighCutOff 7 Any number Sets the new upper truncation point Double CB SetAssum Example This example changes the name of the assumption in cell B3 to Revised Assumption CB SetAssum Range B3 1 Revised Assumption CB SetAssum Related Calls Name Description CB DefineAssumND Defines or changes assumptions in selected cells without using a dialog CB GetAssum Retrieves information for a specific assumption cell CB SetCBAutoLoad This call specifies whether to automatically start Crystal Ball whenever Excel starts called autoloading The original default setting
253. ne kiarn Ep erigir avr 102 CI DefmneAliParas Example 3 score 102 CB DefineAltParms Related Calls ooo gy 102 CB DefineAssum NM nose E NUM Be ad 102 Ex reda nen ey E 103 CP DeineAssum Example 2 sei AA 103 CB DefineAssum Related Calls EAT Seas 103 GB Deine ONDE essi sce FREQ ote EU ned uc a Fdw ER ss 103 CB Deie Seg ND Example Laia ze DR CE DehinessumND Example 2 caprina AAA AA 107 Defining Custom Distributions abs are gt 1 CB DefineAssumND Custom Distribution soe ir ead d Reed RE 108 CH DenneAssumiN Related Calls 222224222dusuadk ep raeb r paacche d epa 108 CB DefineDecVar T sees sexe TT days Vsus Risus pss sus 108 o AMM ERE PACCO eoa Re E dw es s 108 LB DefineDecVar Related CAE ua das cos AAA e ERA Rab ACERO ipe DEN CB DeimeDecVubNE A ex V pb a CN Eq Dad wed b d eed d 109 CB DefineDecVarND Example 1 m e ng CR Dehe Dec eS Lus cows eon pase did NRN A EET FANNE 111 CA DefineDecVarND Exetple 3 rr ARA AAA 111 CB DefineDecVarND Example 4 dus eus est TE Meus e254 seus 111 CE Denm Dee VEND ale inc oexsxtescpElaiusseddwtikesixdwieerb bie CB DefineDecYarND Related Calls oe Lacs cano Oe COGI Ur Ke CA NAREN KNA d is CB DefineFore er ver 44 pas dd bas 444 ad R 112 CE Denne Fore Empe adip doe 3 dock eR d opo dO db sd RUND LE Dc REA CUI
254. ned to OptRuntime followed by an underscore and the name of the selected event Any required and optional parameters appear in parentheses following the name You insert code as usual using any appropriate VBA code and macros from the Crystal Ball and OptQuest Developer Kits For example you can set cell values or perform other operations described elsewhere in this Overview document or the Crystal Ball Developer Kit User Manual Then when the selected event occurs the code runs Important Note In any event handler that modifies values or formulas within an Excel workbook or calls functions that could modify values you should insert the following code Indicate this event was handled PortfolioOptRuntime EventHandled where PortfolioOptRuntime is an OptRuntime object This code informs the optimization engine that events are being handled and allows correct processing in the case where event handlers modify values in the Excel workbook It does not matter where the code is placed as long as it is within the event handler Event Signatures The following are signatures for each of the event macros in OptRuntime e BeforeOptimizationEvent on page 281 e BeforelterationEvent on page 281 e BeforeSimulationEvent on page 282 e AfterSimulationEvent on page 282 e AfterlterationEvent on page 282 e AfterOptimizationEvent on page 282 e EfficientFrontierEvent on page 283 The subroutine names shown
255. ng For Index 18 cbBftOutputAssumRepor t Astring that indicates the report name String n a Used with Valuel True to specify a report name string For Index 23 cbBftFitDistLockParam The index of a lockable parameter from Table 53 see Description Integer The index number of a lockable parameter for the distribution specified in Value1 all from Table 53 see Description Specifies one of the following distribution parameters to lock The following from Table 53 can be used as Value2 parameters e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use Value3 to specify the value of the target parameter For Index 24 cbBftFitDistLockParamCl ear The index of a lockable parameter from Table 53 see Description Integer The index number of a lockable parameter for the distribution specified in Value1 all from Table 53 see Description Specifies one of the following distribution parameter s to clear The locking settings and values are cleared The following from Table 53 can be used as Value2 parameters e Gamma distribution Location Shape parameters e Lognormal distri
256. ng sections are included in this group CB AboutBox on page 42 CB CheckData on page 67 CB CheckDataND on page 68 CB EnumAssum on page 115 CB EnumCorrelation on page 118 CB EnumDecVar on page 120 CB EnumFore on page 121 Crystal Ball Tools 37 e CB GetVersion on page 176 e CB GetWorksheetVersion on page 178 e CB IsCBObject on page 179 e CB Iterations on page 180 e CB RuntimeMode on page 200 38 Crystal Ball Developer Kit Overview Crystal Ball Macro Calls In This Chapter A A A A 42 COI a Gott ac san A o 42 LS MIT ndi ua a naa tried a ee A ida al ae a 42 CB Mr IZ PTT 43 ET oc i mr 43 CB Seat png 44 CB ALT T Ip p EY 45 EENE SU nere eR ern E 46 ro pup erem Ctr O eared On TT NE 46 ndr ub oT T weed deee 55 CR BODL i pj AT Ded 56 Ir TR aid REE 59 rre me yq RrwaS 60 iste per E EE AT pat sient A E E A bene kway nied Sad T A T 61 CRIME rr A A OA E d AE dt T Mc 63 CANES a EA POER A TE dl 64 A ada ee a Re ee ee Ver Ha DU n 67 CORSA p 68 COSA pana dr ds do aa en MU 69 CB Clee DRI Rr LapaTEMa eae 70 CB OBAMA 70 A O T 71 LEM D o O o y a bine bee 72 QR Cr A o A 72
257. ns M ree 172 CR GeRunP ren Related Cal iG soca dd oa ode as o es VES CR ou o AM 173 CB GerTwoDSumalstionOpton Example De vcionin 542 RR ARR RR RERO RR 176 CB GetTwoDSimulationOption Example2 eee oe gas T er x 176 CB GetTwoDSimulationOption Related Calls o ooo oooo o o 176 CB GetVersion EELE T Edd exe EEA TEN EL E O 176 CB GetVersion Example add s 177 ae Rete MAA oe o edge P CB GetWorksheetVersion a SR Side pda ERE 178 CIL Ger Worksheet Version Example 5224242222224 aE RR doPaue REPE RRGCSKE RS 178 CB GetWorksheetVersion Related Calls TT rer bus Tos sa 179 n d A A 179 CB ICBObIest BXataple cuu aan AA AA aia 179 CB IsCBObject Related Calls R T T bd 180 AP tennens 1 CB Iterations Example 1 180 CB Iterations Example2 rer Tm 180 CB Iterations Related Call er aus TT or eds er TS er 180 CE LOCO AR da Tee doc dod eee rer eee ara 181 CB LockFitParm Example Lai hadas bd d bd Rab go p dE RR 182 CB LockFitParm Related Calls ads i34 Pad ay 182 CE ROME 4 0274 a Xa oL del op Re OR aee qo dC CS det de oen DR CB MacroResult Example rap aio di 183 CB MacroResult Related Call A E E EET 183 qim ro op EM ES CB MacroResultDetail Example RERS RRA beds
258. ns for people who are not users of Crystal Ball e Appendix A Using the OptQuest Developer Kit Describes how to use the Crystal Ball Decision Optimizer OptQuest Developer Kit to automate OptQuest optimizations e Appendix B Using the Predictor Developer Kit Describes how to use the Predictor Developer Kit included with all versions of Crystal Ball to automate Predictor time series forecasts Documentation Changes For greater consistency in terminology between the Crystal Ball Developer Kit and VBA e Theterm macro describes a sequence of VBA code created using the Crystal Ball Developer Kit e The term function describes a Developer Kit element that returns a value For example the CB GetCertainty function returns the probability of reaching the specified certainty value e Theterm subroutine describes a Developer Kit element that does not return a value for example CB AboutBox e Theterm call or macro call is used generically to describe any Developer Kit function or subroutine for example The next section describes new Crystal Ball Developer Kit calls In this version of the Crystal Ball Developer Kit all macro calls are listed together in alphabetical order in Chapter 3 For lists of macro calls grouped by functionality see Chapter 2 For information on how the Developer Kit calls have changed since the 2000 5 5 5 version see Chapter 4 Changes from Previous Versions Technical
259. ns the certainty level of achieving a forecast value at or below a specific threshold See CB GetCertainty on page 151 CB GetForeDataFN Returns the value for the given trial for a specific forecast cell See CB GetForeData on page 165 CB GetForePercentFN Returns the value corresponding to a percentile for a specific forecast See CB GetForePercent on page 166 CB GetForeStatFN Returns statistic for a specific forecast cell See CB GetForeStat on page 167 CB GetRunPrefsFN Returns a Run Preference setting See CB GetRunPrefs on page 172 CB IterationsFN Returns the number of trials run in a simulation See CB Iterations on page 180 Opening and Closing Crystal Ball The macro calls in this group can be used to e Load open and close Crystal Ball e Set Crystal Ball autoload defaults e Determine if Crystal Ball is loaded The following sections describe macro calls that are used to open and close Crystal Ball e CB CBLoaded on page 59 e CB GetCBAutoLoad on page 151 CB SetCBAutoLoad on page 214 32 Crystal Ball Developer Kit Overview CB Shutdown on page 225 CB Startup on page 230 Setting Up and Running Simulations The macro calls in this group can be used to Identify errors CB MacroResult CB MacroResultDetail Warn about errors Handle Extreme Speed incompatibilities Automate the definition of assumptions and forecasts Select or copy paste or clear
260. nstant Value Index Parameter Index Value Value Parameter Values to Use Description indicate whether the constant is active or not cbExtPredictorResultsSheetNa me 17 A string value representing a sheet name The name of the sheet where extracted Predictor results data is placed The sheet name must follow appropriate sheet naming restrictions cbExtPredictorMethodsSheetNa me 18 A string value representing a sheet name The name of the sheet where extracted Predictor methods data is placed The sheet name must follow appropriate sheet naming restrictions cbExtPredictorResultsHistorical 19 True or False True includes historical data in extracted results False does not include historical data cbExtPredictorResultsFitted 20 True or False True includes fitted data in extracted results False does not include fitted data cbExtPredictorResultsForecast 21 True or False True includes forecasted data in extracted results False does not include forecasteddata cbExtPredictorResultsConfidenc e 22 True or False True includes confidence interval data in extracted results False does not include confidence interval data cbExtPredictorResultsResiduals 23 True or False True includes residuals data in extracted results False does not include residuals data For information on residuals data see the Oracle Crystal Ball Predictor User s Guide
261. ny type It is the equivalent of the Analyze then Close All command This call works on both current and restored results CB CloseAllCharts Example This example runs a simulation and closes all open charts CB Simulation 1000 CB CloseAllCharts Crystal Ball Macro Calls CB CloseAlICharts Related Calls Name Description CB CloseChart Closes the selected chart of the given type CB OpenChart Opens the selected chart of the specified type CB CloseChart This call closes a chart of the specified type and chart ID The chart ID is optional If the chart ID is not specified the currently selected chart is closed If the specified chart is not found a chooser dialog appears No error is returned Currently this call only works on current and not restored results Table 25 CB CloseChart Parameters Parameter VBA Data Type Value Description SimChartType Integer cbChtOverlay 1 cbChtScatter Specifies the type of chart you 2 cbChtSensitiv 3 are closing overlay scatter cbChtTrend 4 sensitivity or trend chart For named constant and index values see the Value column ChartID Optional String Chart ID The chart ID returned by CB EnumChart Table 59 entered directly or using CB EnumChart CB CloseChart Example This example runs a simulation calls CB CheckData because a CB Enum call follows and then closes the next overlay chart in the workbook CB Simulation 1000 CB CheckData
262. o 200 each included trend chart the charts False does not defines the percent scale of the charts 82 Crystal Ball Macro Calls Named Constant Value Index Value Description Value1 Optional Value2 Optional cbRptSensitivityCharts 26 Includes the graph for boolean True includes Integer 1 to 200 each included sensitivity the charts False does defines the percent scale chart not of the charts cbRptScatterCharts 27 Includes the graph for boolean True includes Integer 1 to 200 each included scatter the charts False does defines the percent scale chart not of the charts cbRptChooseOverlay 28 Clears adds and sets Integer See Table 38 If n a the overlay charts to cbChartAdd the selected include in the report chart is added when used with CB SelectChart cbRptChooseTrend 29 Clears adds and sets Integer See Table 38 If n a the trend charts to cbChartAdd the selected include in the report chart is added when used with CB SelectChart cbRptChooseSensitivity 30 Clears adds and sets Integer See Table 38 If n a the sensitivity charts to cbChartAdd the selected include in the report chart is added when used with CB SelectChart cbRptChooseScatter 31 Clears adds and sets Integer See Table 38 If n a the scatter charts to cbChartAdd the selected include in the report chart is added when used with CB SelectChart cbRptDefinedType 32 Selec
263. o Calls Sets the decision variable type to Custom it can assume any value from a list of two or Named Constant Value Index Value Description more specific values supplied with the customData parameter CB DefineDecVarND Example 1 This example defines a new decision variable in cell C9 with a lower bound of 400 an upper bound of 600 a step size of 10 also making the decision variable Discrete and a title of Rent Per Unit Range C9 Select CB DefineDecVarND 400 600 10 Rent Per Unit This definition is the same except the decVarType parameter is used Range C9 Select CB DefineDecVarND 400 600 10 Rent Per Unit cbDecVarTypeDiscrete CB DefineDecVarND Example 2 This example defines a new decision variable in cell D12 with a lower bound of 500 an upper bound of 800 no step size also defining the decision variable as Continuous and a title of Net Income Range D12 Select CB DefineDecVarND 500 800 Net Income This definition is the same except the decVarType parameter is used Range D12 Select CB DefineDecVarND 500 800 Net Income cbDecVarTypeContinuous CB DefineDecVarND Example 3 This example defines a new decision variable in cell F10 with a lower bound of 0 an upper bound of 1 no step size a title of Net Income and a decision variable type of Binary The values of Min and Max are ignored for Binary decision variables but they must b
264. o the parameters when the function returns CB EnumCorrelation Example 1 This example uses asm1Address to represent Assum1 uses asm2Address to represent Assum2 uses corrValue to represent Value and then uses a loop to stop execution when all correlated assumptions have been located As it runs it displays a message box with the first and second assumption in each pair of correlated assumptions along with the correlation value Sub EnumCorr Dim asmlAddress As String Dim asm2Address As String Dim corrValue As Variant Dim count As Variant CB CheckData When asmlAddress asm2Address and corrValue are passed ByRef the value passed into the function is ignored and the next set of values in the enumeration is set in these parameters when the call returns count CB EnumCorrelation asmlAddress asm2Address corrValue While count gt 0 MsgBox Assumption in cell amp asmlAddress amp _ is correlated to assumption in cell amp asm2Address _ by amp corrValue count CB EnumCorrelation asmlAddress asm2Address corrValue Wend End Sub CB EnumCorrelation Example 2 This example uses asm1Address to represent Assum1 uses asm2Address to represent Assum2 uses corrValue to represent Value and then uses a loop to stop execution when all correlated assumptions have been located As it runs it produces a list of the first and second asssumption in each pair of correlated assumptions followed by the
265. oDPercent Integer indicate the 5th and 95th percentiles For Index 7 cbTwoDPercentQuartiles 3 Returned by cbTwoDPercent to cbTwoDPercent Integer indicate quartiles 25 ile increments from O to 100 inclusive For Index 7 cbTwoDPercentQuintiles 4 Returned by cbTwoDPercent to cbTwoDPercent Integer indicate quintiles 20 ile increments from O to 100 inclusive For Index 7 cbTwoDPercentDeciles 5 Returned by cbTwoDPercent to cbTwoDPercent Integer indicate deciles 10 ile increments from O to 100 inclusive For Index 7 cbTwoDPercentlcosatiles 6 Returned by cbTwoDPercent to cbTwoDPercent Integer indicate icosatiles 5 ile increments from O to 100 inclusive For Index 7 cbTwoDPercentCustom 7 Returned by coTwoDPercent to cbTwoDPercent Integer indicate custom percentiles If cbTwoDPercentCustom is supplied as a parameter along with a valid Excel range fills a column oriented range with percentiles in the custom list starting with the cell passed in the range For Index 8 Integer from 2 to 250 inclusive n a Returned to indicate the cbTwoDMSDOption Integer maximum number of uncertainty simulations to display in the output report and overlay chart CB GetTwoDSimulationOption 175 Table 132 CB GetTwoDSimulationOption Value2 Parameter Optional Variant Value or Named Related Value Constant VBA Data Type Index Description For Index 6 True or False boolean n a Indicates whether th
266. occurred such as a formula cell was used for a macro that required a single value cell CB MacroResultDetail Example This subroutine checkresult clears the specified range defines a normal distribution in cell A1 defines a forecast in cell A2 runs a simulation and displays a dialog for each of the CB MacroResultDetail properties Then it clears the Crystal Ball data in cells Al and A2 and stops Sub checkresult CB MacroResultDetail 185 Range A1 A2 Select CB ResetND CB ClearDataND Range A1 A2 Clear Range Al Select ActiveCell Value 0 CB DefineAssumND cbDfaNormal 0 1 Range A2 Select ActiveCell Value A1 CB DefineForeND CB Simulation 1000 MsgBox CB MacroResultDetail DialogResult MsgBox CB MacroResultDetail ElapsedTimeInMS MsgBox CB MacroResultDetail Msg MsgBox CB MacroResultDetail MsgDetails MsgBox CB MacroResultDetail MsgTitle MsgBox CB MacroResultDetail NewValue MsgBox CB MacroResultDetail OldValue Range A1 A2 Select CB ResetND CB ClearDataND Range A1 A2 Clear End Sub CB MacroResultDetail Related Call Name Description CB MacroResult Indicates if a macro call worked correctly including limited error information CB OpenChart This call opens a chart of the specified type and chart ID The chart ID is optional If no charts of the specified type exist one is created and i
267. odMultiSim 2 cbBtsAnalyze 4 Returns the constant of the selected analysis setting cbBtsAnalyzeStat 1 cbBtsAnalyzePercent 2 or cbBtsAnalyzeCapMetrics 3 cbBtsPercent 5 Returns the constant of the currently selected percentile setting for use if cbBtsAnalyze is called with cbBtsAnalyzePercent 2 cbBtsPercentTenNinety 1 cbBtsPercentFiveNinetyFive 2 cbBtsPercentQuartiles 3 cbBtsPercentQuintiles 4 cbBtsPercentDeciles 5 cbBtsPercentlcosatiles 6 or cbBtsPercentCustom 7 If the returned value is cbBtsPercentCustom 7 you can use that constant as an Index2 parameter to return a range of custom values cbBtsSample 6 Used with Index2 to return the current bootstrap sample settings for cbBtsNumberSamples 1 or cbBtsTrialsPerSample 2 cbBtsForeOption 7 Returns the constant of the current forecast display setting coBtsShowDefinedFore 1 cbBtsShowTargetFore 2 or coBtsHideFore 3 CB GetBootstrapOption 149 Table 96 CB GetBootstrapOption Index2 Parameter Optional Integer Related Value Named Constant Value Index Description For Index 5 cbBtsPercent cbBtsPercentCustom 7 Returns a range of custom Integer percentile values in the range specified with Value For Index 6 cbBtsSample cbBtsNumberSamples 1 Used with cbBtsSample to Integer return the number of bootstrap samples to use For Index 6 cbBtsSample cbBtsTrialsPerSample 2 Used with cbBtsSample to Integer return the n
268. om program intricacies e Building custom reports or automating analysis when time series forecasts are complete e Setting up specialized time series forecast environments The Predictor Developer Kit provides a link between Predictor and your application It consists ofa number of object oriented development classes that control many aspects of Predictor Each Crystal Ball product comes enabled to use the Predictor Developer Kit so that applications you develop can be run by other users with appropriate licenses The Predictor Developer Kit provides a framework of classes that you can use with Predictor to perform time series forecasts It isa COM Component Object Model object which allows the use of older languages that support ActiveX objects such as Visual Basic 6 0 VB6 C VBA and others About the Predictor Developer Kit 285 Who Should Use This Kit The Predictor Developer Kit is appropriate for advanced users who want to automate repetitive spreadsheet time series forecasts This documentation assumes that readers are familiar with a COM compatible development platform and Crystal Ball with Predictor What This Kit Includes In addition to this Developer s Guide the Predictor Developer Kit includes the following files available in the specified folders under the Crystal Ball installation folder by default C Program Files Oracle Crystal Ball e CBCOMDevkKit tlb in the Bin folder accessible directly and through CBDevKit
269. on ID or string returned by build number counting VersionType from the left For details see Table 134 CB GetWorksheetVersion Example This example puts the third section of the build number of the version of Crystal Ball used to create the data on Sheet in cell A2 of the active worksheet and puts the version ID string of the version of Crystal Ball used to create Sheet 2 in cell B2 If the full build number is 11 1 159 0 and 178 Crystal Ball Macro Calls the version ID number is 11 1 1 1 00 159 is placed in cell A2 and 11 1 1 1 00 is placed in cell B2 Range A2 Value CB GetWorksheetVersion Sheet1 cbFullBuildVersion 3 Range B2 Value CB GetWorksheetVersion Sheet2 cbProductVersion CB GetWorksheetVersion Related Calls Name Description CB GetVersion Returns all or part of the current Crystal Ball version as a full build number or version ID number CB IsCBObject This function determines if a worksheet or workbook contains Crystal Ball data Table 137 CB IsCBObject Returned Data Type Returned Value Returned Data Type Whether the current worksheet or workbook contains Crystal Ball data boolean Most of the Developer Kit subroutines and function will not work if the active worksheet or workbook does not contain Crystal Ball data Table 138 CB IsCBObject Parameters Parameter VBA Data Type Value Description AnObject Variant An Excel workbook or Points to the worksh
270. on horizontal grid lines False turns them off For Index 6 Integer cbTypReverseCumulCert 1 Displays the reverse cumulative certainties view of the chart For Index 6 Integer cbTypCumulCert 3 Displays the cumulative certainties view of the chart For Index 6 Integer cbTypCertCenteredOnMedian 4 Displays the chart with certainties centered on the median For Index f Integer cbValZeroBased 1 Uses zero based value axes normalizing the lowest forecast value to 0 This constant is included for compatibility with Crystal Ball 2000 x 5 x For Index f Integer cbValRelative 2 Uses relative value axes the actual minimum and maximum values For Index 7 Integer cbValMinMaxDiv 3 Uses value axes by setting a minimum Value2 and a maximum Value3 so you can focus on a particular value range For Index 8 Integer Any integer between O and 100 n a Sets the first certainty band to inclusive display Use this with Value2 through Value7 Note cbTypCertCenteredOnMean 2 is now obsolete Table 184 following describes the Value2 parameter Table 184 CB TrendPrefsND Value2 Parameter Values Optional Variant Used With Specified Parameters and Values For Index 7 and Valuel 3 Double Value Any number Description Defines the minimum value for the value axis For Index 8 Integer Any integer between 0 and 100 inclusive Sets a second certainty band to display Use this wit
271. on tool without displaying dialogs CB GetTwoDSimulation Option Returns current settings for the 2D Simulation tool CB TwoDSimulationND The 2D Simulation tool helps evaluate risk by estimating the uncertainty and variability for a given forecast using two dimensional simulation This call runs the 2D Simulation tool and displays results without using a dialog This call returns a variant Note Before calling CB TwoDSimulationND reset the Crystal Ball simulation Table 186 CB TwoDSimulationND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 187 Valuel Optional Integer Table 188 Value2 Optional Variant Table 189 236 Crystal Ball Macro Calls Table 187 CB TwoDSimulationND Index Parameter Required Integer Named Constant Value cbTwoDChooseTarget Index Description Sets the target forecast for the 2D simulation operation operates on the forecast in the currently selected cell use cell Select first to select the cell cbTwoDChooseAssum Works with Value to choose assumptions for the uncertainty loop the variability loop or to clear the list operates on the assumption in the currently selected cell use cell Select first to select the cell cbTwoDOuterSimTrials Used with va1ue1 to specify the number of trials in the outer uncertainty simulation loop cbTwoDInnerSimTrials Used with va1ue1 to specify the number of trials in th
272. onal boolean True or False If False returns the statistic if True returns the p value The default is False DistBestFit Integer See Table 76 If only one distribution is passed for Dist DistBestFit returns the index of that distribution Otherwise it returns the index of the best fitted distribution CB Fit 131 Parameter VBA Data Type CriterionBestFit Integer Value See Table 77 Description If a specific ranking method is passed for Criterion CriterionBestFit returns the index of this ranking method Otherwise it returns the index of the selected ranking method The following table shows Dist parameter values used to select a distribution for fitting You can only fit to distributions listed in this table Table 76 CB Fit Dist Parameter Values Required Integer Named Constant Value Index Value Description cbDfaNormal 0 Fits to a normal distribution cbDfaTriangular 1 Fits to a triangular distribution cbDfaPoisson 2 Fits to a Poisson distribution cbDfaBinomial 3 Fits to a binomial distribution cbDfaLognormal 4 Fits to a lognormal distribution cbDfaUniform 5 Fits to a uniform distribution cbDfaExponential 6 Fits to an exponential distribution cbDfaGeometric T Fits to a geometric distribution cbDfaWeibull 8 Fits to a Weibull distribution cbDfaBeta 9 Fits to a beta distribution cbDfaGamma 12 Fits to a gamma distribution cbDfa
273. oolean in later versions of Crystal Ball the values are Integer Models from Crystal Ball 2000 5 5 5 that use this constant will not run successfully in later versions of Crystal Ball until the constant values are edited The following Valuei values Table 149 are used with the Index parameter to set Crystal Ball run preferences CB RunPrefsND 197 Table 149 CB RunPrefsND Valuei Parameter Values Required Variant Used With Specified Values of Index For Index 1 coRunMaxTrials Long Value Any positive whole number Description Sets the maximum number of trials For Index 2 cbRunStopOnError Boolean True or False True stops a simulation on calculation errors in forecast cells False does not For Index 4 cbRunSameRandoms Boolean True or False True uses the same sequence of random numbers False does not For Index 7 cbRunSamplingMethod Boolean True or False OR cbSamLatinCube True or coSamMonteCarlo False True uses Latin Hypercube False uses Monte Carlo For Index 8 coRunSampleSize Integer A whole number between 10 and 5000 Sets the sample size for Latin Hypercube sampling For Index 10 cbRunCorrelationsOff Boolean True or False True turns off correlations False turns on correlations For Index 26 cbRunMinimizeHost Boolean True or False True minimizes Excel during simulations False does not For Index 27
274. or Named Parameter VBA Data Type Constant Index Description VersionType Variant A constant as specified n a n a Optional below if O or unspecified the Crystal Ball version ID is returned as a string equivalent to cbProductVersion VersionType Variant cbProductVersion 0 Returns all or part of the Optional Crystal Ball version ID for example 11 1 1 1 00 can be used with Index to return only a portion of the version ID VersionType Variant cbFullBuildVersion 1 Returns all or part of the Optional Crystal Ball build number for example 11 1 159 0 can be used with Index to return only a portion of the build number Index Optional Integer An integer from 1 to the n a Returns the specified number of sections in the portion of the version ID string returned by or build number VersionType counting from the left If Index 3 159 would be returned for cbFullBuildVersion in the example above the maximum value for Index in this example would be 4 If Index O or is not specified the full string for VersionType is returned CB GetVersion Example For Crystal Ball version 11 1 1 0 00 this example places the string 11 1 1 0 00 in cell A2 and a string with the full build number 11 1 63 0 into cell B2 Range A2 Value CB GetVersion Range B2 Value CB GetVersion cbFullBuildVersion CB GetVersion 177 CB GetVersion Related Calls Name Description CB GetWorksheetVersion Returns th
275. ord to register for that workbook aTurnon boolean True or False Specifies whether or not workbook protection is active True activates protection and False removes it Use this option when you call this macro externally such as from Visual Basic CB WorksheetProtection 241 CB WorksheetProtection Example 1 This example activates the target worksheet passes the password passwd runs a simulation and resets Crystal Ball Sub WorksheetProtectionExamplel ThisWorkbook Worksheets Sheet3 Activate The above call activates the target worksheet CB WorksheetProtection passwd True The above call passes current password to Crystal Ball CB Simulation 1000 CB ResetND The above calls run and reset the simulation End Sub Note To apply protection to worksheets that do not have a password use this CB WorksheetProtection True CB WorksheetProtection Example 2 This example activates the target worksheet unprotects the sheet with the current password passes a new password and protects the sheet Sub Worksheet ProtectionExamp1le2 ThisWorkbook Worksheets Sheet3 Activate The above call activates the target worksheet CB WorksheetProtection passwd False The above call unprotects sheet with current password CB WorksheetProtection passwd2 False The above call passes a new password CB WorksheetProtection passwd2 True The above call protects the sheet End Sub CB WorksheetPr
276. ording to the Value setting cbChtMeanLine 5 Turns on and off the mean line according to the Value setting cbChtHorizGrids 6 Turns on and off horizontal grid lines according to the Value setting Note The following Index constant is obsolete in Crystal Ball 7 x and later including 11 x cbChtRedrawFrequency Index 4 The Value parameter Table 24 works with the Index parameter Table 23 to set forecast and assumption chart preferences Table 24 CB ChartPrefsND Value Parameter Values Required Variant Used With Specified Named Constant or Values of Index boolean Value Index Value Description For Index 1 cbTypArea 1 Changes the assumption cbChtChartType Integer or forecast chart type to an area chart For Index 1 cbTypOutline 2 Changes the assumption cbChtChartType Integer or forecast chart type to an outline chart CB ChartPrefsND 65 Used With Specified Named Constant or Values of Index boolean Value Index Value Description For Index 1 cbTypColumn 3 Changes the assumption cbChtChartType Integer or forecast chart type to a column chart For Index 2 cbDstFrequency 1 Changes the distribution cbChtDistType Integer type to a frequency distribution For Index 2 cbDstCumulative 2 Changes the distribution cbChtDistType Integer type to a cumulative frequency distribution For Index 2 cbDstReverseCumul 3 Changes the distribution
277. oreDataFN Table 118 CB GetForeData Returned Data Type Returned Value Returned Data Type The value of the given trial for the specified forecast cell Variant Table 119 CB GetForeData Parameters Parameter VBA Data Type Value Description ForeReference Variant In a macro Range B3 Points to the desired f ll In a worksheet B3 Clear ca Index Long A whole number from 1 Number of the trial whose through the number of value you want to return trials in the simulation CB GetForeData Example 1 This example runs a simulation of 1000 trials and then pastes the value of the 100th trial of the forecast in B1 into cell A10 In a macro you can enter CB Simulation 1000 Range A10 Value CB GetForeData Range B1 100 CB GetForeData 165 CB GetForeData Example 2 This example pastes the value of the 100th trial of the forecast in B1 into the cell where the function is entered In a worksheet you can enter CB GetForeDataFN B1 100 CB GetForePercent This function calculates the value of the specified forecast that corresponds to the specified percentile You can call this function from either a macro or a worksheet Note To call this function from a worksheet use the name CB GetForePercentEN Table 120 CB GetForePercent Returned Data Type Returned Value Returned Data Type Forecast value that corresponds to the specified percentile Variant You must run a simulat
278. ormation for example distribution type and parameters Table 61 CB EnumCorrelation Returned Data Type Returned Value Returned Data Type The current count of correlations left in the enumeration including the correlation returned by Variant this call For best results call CB CheckData once atthe beginning ofan enumeration to resetthe sequence of correlated assumptions You should also call CB CheckData each time you add or delete data If the returned string is 0 all correlated assumptions have been enumerated You can only call this function from a subroutine or another function You cannot call this function from a worksheet Table 62 CB EnumCorrelation Parameters Parameter VBA Data Type Description Assum1 String Represents the first assumption in a pair of correlated assumptions by reference returned as the absolute cell reference of the next correlated assumption in the format workbook sheet A 1 Assum2 String Represents the second assumption in a pair of correlated assumptions by reference returned as the absolute cell reference of the next correlated assumption in the format workbook sheet A 1 Value Variant Represents the correlation value associated with Assum1 and Assum2 by reference 118 Crystal Ball Macro Calls Notice that all parameters are by reference The values passed into CB EnumCorrelation are ignored The next set of enumeration values is assigned t
279. osen forecasts Use after cbChooseDecVarAdd cbChooseDecVarAdd 3 Adds the forecast in the selected cell to the list of chosen forecasts Use cbChooseDecVarChosen after this option cbChooseDecVarClearList 4 Clears the list of chosen forecasts Run a simulation before you call CB ExtractDataND Extraction of data from restored results is not supported See the Oracle Crystal Ball User s Guide for more information on extracting data CB ExtractDataND Example 1 This example runs a simulation and then sets preferences to extract the decile percentile data for all the forecasts It then extracts the data to a new worksheet in the active workbook CB Simulation 1000 CB CheckData CB ExtractDataND cbExtChooseFore cbChfAll CB ExtractDataND cbExtDataType cbDatPercentiles CB ExtractDataND cbExtPercentiles cbPctDeciles CB ExtractDataND cbExtExistingSheet True CB ExtractDataND cbExtOK CB ExtractDataND Example 2 You can now use CB ExtractDataND to extract more than one type of data To do this use cbExtDataType followed by the type of data and then follow that by a boolean Value2 parameter For example the following lines of code extract both statistics and values CB CheckData CB ExtractDataND cbExtDataType cbDatStatistics True CB ExtractDataND cbExtDataType cbDatValues True CB ExtractDataND cbExtOK CB ExtractDataND Related Calls Name Description CB CreateRpt Creates a Cry
280. otection Example 3 This example activates the target worksheet unprotects the sheet with the current password clears the password by passing an empty string and leaves the sheet unprotected Sub Worksheet ProtectionExample3 ThisWorkbook Worksheets Sheet3 Activate The above call activates the target worksheet CB WorksheetProtection passwd2 False The above call unprotects sheet with current password CB WorksheetProtection False 242 Crystal Ball Macro Calls above call clears the password End Sub CB WorksheetProtection 243 244 Crystal Ball Macro Calls Changes from Previous Versions In This Chapter A otk ep bo asain Ra a aaa BUT AN RR 245 ed LETIN D aain onani PET T A 245 Added m Crystal AA A a a ie eee toe idi ebd 246 Not Incladed i This VEISIOU iibi eer Corb a a ai a ne ee GRE a 247 Ghanpes to Exito WANS asias pati gules a s bid aN E a NA 249 Other Changes ai nnen a a wanna eid aU Ra ai E 261 Introduction This appendix lists differences between the 2000 5 5 5 version of the Crystal Ball Developer Kit and this version Most of these differences also apply to other 2000 x 5 x versions You can learn about new calls now available for use in future code and can use the lists of omitted and changed calls to troubleshoot conversion problems in existing code Added in Crystal Ball 11 1 1 0 00 The following new calls were added to version 11 1 1 0 00 of the Crystal Ball Developer Kit Th
281. per Kit subroutines and functions You can also use the Crystal Ball Developer Kit macros to create controls that extract data create charts and reports and more When you run simulations the Crystal Ball Control Panel is switched off by default However you can use Visual Basic or VBA to switch it on again using appropriate calls to CB Simulation or CB RunPrefsND Even if the Control Panel dialog is displayed though the Run Analyze and Help menus are hidden Your application can use any of the Crystal Ball features accessible through the Developer Kit If users have appropriate licenses you can also include Predictor time series analyses in your applications and users can run simulations in Extreme speed Unless otherwise specified defaults are pulled from the user s preference files These defaults can be set through Crystal Ball s preference dialogs or preferences macro calls such as CB RunPrefsND in the Crystal Ball Developer Kit For more information see Chapter 5 Crystal Ball Runtime CB RuntimeMode Example This example hides the Crystal Ball toolbar and menus resets the current simulation and runs a simulation of 5000 trials CB RuntimeMode CB ResetND CB Simulation 5000 200 Crystal Ball Macro Calls CB RuntimeMode Related Call Name Description CB Simulation Runs a Crystal Ball simulation CB SaveResults This subroutine opens the Save Results dialog so you can save results data and charts fo
282. properties of this class summarize optimization information for a single Efficient Frontier test point Developing Optimization Code This section discusses the development environment resources available to help you learn and use the Optquest Developer Kit and an overview of how to start and continue coding an optimization with illustrations from sample code Development Environment For development with the OptQuest Developer Kit you can use any development environment that supports the use of Microsoft COM components Such an environment lets you use VB6 VBA supplied with Microsoft Word and Excel C ASP and similar COM compatible languages you will still need the Microsoft NET Framework To access the OptQuest Developer Kit you must reference the COM object named CBCOMDevkKit which is registered on your computer during the installation Development Resources In addition to this book the OptQuest Developer Kit contains two other files with information about kit contents and how to use it CB Com Devkit chm and OptDevKitRuntimeSample xls CB Com Devkit chm This help file is a reference with lists and descriptions of methods and properties in OptQuest Developer Kit classes It is located in the Docs folder beneath the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball Docs You can open and use CB Com Devkit chm directly from that folder at any time When you first open CB Com Devkit ch
283. r of periods to forecast and Predictor results window display options PredResults PredResultsWindow This class provides access to the Predictor results window and enables you to set items such as selected series and method This class enables you to control the Predictor results dialog and access all of the controls on the form Developer Kit Use and Structure 289 PredResults PredSeriesResult This class provides access to per series result information This class provides access to information such as series name best fit method forecast adjustments result statistics series historical data values and forecast data values An enumerator property of the PredResults class Series enables you to access each series by index into the input data range Developing Time Series Forecasting Code For development with the Predictor Developer Kit you can use any development environment that supports the use of Microsoft COM components Such an environment lets you use VB6 VBA supplied with Microsoft Word and Excel C ASP and similar COM compatible languages you will still need the Microsoft NET Framework To access the Predictor Developer Kit you must reference the COM object named CBCOMDevkKit which is registered on your computer during the installation In addition to this book the Predictor Developer Kit contains two other files with information about kit contents and how to use it CB Com Devkit chm and Toledo Gas xls CB Com De
284. r the current simulation To run this subroutine you must first run a simulation or the dialog does not open The simulation must be completed or stopped Once you have saved a results file with cbr extension you can use CB RestoreResults or CB RestoreResultsND to open it and restore the results CB SaveResults is similar to CB SaveRun available in Crystal Ball 2000 5 5 5 However CB SaveRun stored an entire simulation not just the results CB RestoreRun and CB RestoreRunND were used to restore the saved simulation The existing simulation had to be reset before the saved simulation could be loaded and only one simulation could be restored at a time This differs from the current requirements for CB RestoreResults and CB RestoreResultsND discussed beginning in CB RestoreResults on page 193 See the Oracle Crystal Ball User s Guide for more information on saving simulation results Note Before you save run results run a simulation CB SaveResults Example This example runs a simulation of 1000 trials and then opens the Save Results dialog CB Simulation 1000 CB SaveResults CB SaveResults Related Calls Name Description CB RestoreResults Restores simulation results from a file using a dialog CB RestoreResultsND Restores simulation results from a file without a dialog CB SaveResultsND Saves current simulation results without a dialog CB Simulation Runs a Crystal Ball simulation TB SaveResults 201
285. rStatistics class 273 OptRuntime ResultsWindow class 273 OptRuntime RuntimeEfficientFrontier class 273 OptRuntime TestPointInfo class 274 OptSetup class 272 OptSetup Constraint class 272 OptSetup Decision class 272 OptSetup Objective class 272 OptSetup OptEfficientFrontier class 272 OptSetup OptOptions class 272 OptSetup Requirement class 272 P parameters defining 99 pasting CB data 190 Index 297 A B C D E F G H percentiles getting from assumptions 143 getting from CB forecasts 166 reversing 196 precision control getting preferences 163 setting preferences 220 Predictor Developer Kit 285 installation 286 namespace 287 structure 286 Predictor Developer Kit classes 287 Predictor setup classes 288 PredResults class 289 PredResults PredResultsPreferences class 289 PredResults PredResultsWindow class 289 PredResults PredSeriesResult class 290 PredSetup class 288 PredSetup PredDataAttributes class 288 PredSetup PredInputData class 288 PredSetup PredMethods class 289 PredSetup PredOptions class 289 PredSetup PredSeries class 289 preferences assumption 44 CB cells 60 61 CB run 194 195 forecast window 63 64 forecast windows format 135 getting run 172 R reports creating 80 resetting simulations 191 192 resources OptQuest development 274 restoring simulation results 193 results macro 182 184 results saving 201 202 reversing percentiles 196 run prefe
286. ram cbDfa distribution Variant names for the following distributions from Table 53 gamma lognormal Student s t Weibull binomial hypergeometric Description Returns the locked value of the specified distribution and the parameter specified with va1ue2 Table 92 CB GetBatchFitOption Value2 Parameter Optional Variant Used With Specified Named Constant or Values of Index boolean Value Index Value For Index 23 One of the parameter n a cbBftFitDistLockParam numbers from Table 53 for Integer the distribution specified with Value1 gamma lognormal Student s t Weibull binomial hypergeometric Description Returns the locked value of the specified parameter for the distribution specified with Valued The numbers listed for the following parameters in Table 53 can be used for Value2 e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter CB GetBatchFitOption 147 Used With Specified Values of Index Named Constant or boolean Value Index Value Description e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter CB GetBatchFitOption Example 1 This example returns the address of the selected input data range as a string CB GetBatchFi
287. rameters Parameter VBA Data Type Description Index Integer Specifies which extract preference you are setting See Table 66 following Value Optional Variant Specifies settings for the preference indicated by the Index See Table 66 for more information Value2 Optional Variant Specifies whether to extract the specified data type See CB ExtractDataND Example 2 The following are named constant and index values for the Index parameter Table 66 CB ExtractDataND Index Parameter Values Required Integer with Related Value Parameter Values Optional Variant Index Parameter Named Constant Value Index Parameter Index Value Value Parameter Values to Use Description cbExtOK 1 n a Extracts the data Use this parameter after setting other extract options CB ExtractDataND 123 Index Parameter Named Constant Value cbExtDataType Index Parameter Index Value Value Parameter Values to Use See Table 67 Description Specifies the type of data to extract Used with these Value parameter values described in Table 67 1 cbDatForeValues CB 2000 x or 5 x only 1 cbDatValues CB 7 x and 11 x or later 2 cbDatStatistics 3 cbDatPercentiles 4 cbDatFrequencies 6 cbDatSensitiv 7 cbDatCapMetrics cbExtChooseFore See Table 68 Specifies which forecasts to include Used with these Value parameter values described in Table 68 1 cbChfAll 2 cbChfOpe
288. rategies outlined in Coding an Optimization on page 277 Although this information refers to the OptQuest Developer Kit basic rules and guidelines apply to the Predictor Developer Kit 290 Using the Predictor Developer Kit Note Although coding is similar in the OptQuest and Predictor Developer Kits ignore the sections on user defined event macros and events in VBA The Predictor Developer Kit does not support user defined events Developing Time Series Forecasting Code 291 292 Using the Predictor Developer Kit A B C D E F G M NO P R S TU VW Index Symbols NET Framework version 270 287 Numbers 2D Simulation tool 173 236 64 bit use 271 287 A about dialog CB 42 AfterIterationEvent 282 AfterOptimizationEvent 282 AftersimulationEvent 282 alert macros 42 43 applications custom 200 assumptions correlating 77 custom 107 defining 102 103 defining parameters 99 enumerating 115 118 fitting distributions 131 160 170 219 getting correlation 153 getting percentile values 143 preferences 44 retrieving information 140 selecting 207 assumptions setting attributes 213 autoload 59 151 214 230 B Batch Fit tool 46 144 BeforelterationEvent 281 BeforeOptimizationEvent 281 BeforeSimulationEvent 282 Bootstrap tool 55 56 148 C CB Com Devkit chm 271 274 287 CB Tools 96 148 2D Simulation 173 236 Batch Fit 46 144 Bootstrap 55 56 Data Analysis 91 154 Dec
289. reateRptND cbRptOK CB CreateRptND Example 2 This example resets any previously run simulation then clears the current assumption list adds B5 to the assumption list and turns on the assumption parameter option the second cbChaChosen use Other assumption preferences default to the current setting in the Create Report dialog Finally the example generates the report No forecast or simulation charts will appear since CB ResetND cleared all previous simulation information CB ResetND CB CheckData CB CreateRptND cbRptChooseAssum cbChaClearList CB CreateRptND cbRptChooseAssum cbChaChosen Range B5 Select CB CreateRptND cbRptChooseAssum cbChaAdd CB CreateRptND cbRptChooseAssum cbChaChosen Cb CreateRptND cbRptAssumParam True CB CreateRptND cbRptOK ET YT TI E CB CreateRptND Related Calls Name Description CB CreateRpt Sets report preferences and creates a report from the current simulation and restored results optimization or time series forecast using a dialog CB ExtractData Extracts data from the current simulation and restored results optimization or time series forecast using a dialog CB ExtractDataND Extracts data from the current simulation and restored results optimization or time series forecast without a dialog 90 Crystal Ball Macro Calls CB DataAnalysis This call launches the Data Analysis tool wizard This tool helps you import data directly into Crys
290. reezes the forecast For Index 20 cbForLSL Variant A numeric value double a string representing a cell reference such as B1 or coParmUndefined Sets the lower specification limit LSL for the forecast 222 Crystal Ball Macro Calls Used With Specified Values of Index Value Description For Index 21 cbForUSL Variant A numeric value double a string Sets the upper specification limit USL for representing a cell reference such as the forecast B1 or coParmUndefined For Index 22 cbForTarget Variant A numeric value double a string Sets the target value for the forecast representing a cell reference such as B1 or coParmUndefined CB SetFore Example 1 This example changes the forecast in cell B7 to open the forecast window automatically during the simulation CB SetFore Range B7 4 True CB SetFore Range B7 5 O CB SetFore Example 2 This example turns on precision control for the forecast in cell B7 selects the absolute size of the confidence interval sets the size at 10 forecast units and selects the use of the mean in checking precision CB SetFore Range B7 6 True CB SetFore Range B7 7 True CB SetFore Range B7 8 10 CB SetFore Range B7 10 True CB SetFore Related Calls Name Description CB DefineForeND Defines forecasts in selected cells without a dialog CB GetFore Retrieves information for a specific fore
291. refs CB SensPrefsND CB SetCBWorkbookPriority CB SetFitRange CB TrendPrefs CB TrendPrefsND CB ScatterPrefs CB ScatterPrefsND CB SetCBAutoLoad CB SetExcel2007ForegroundMode CB Shutdown CB Startup CB WorksheetProtection Not Included in This Version The following calls available in Crystal Ball 2000 x 5 x or earlier versions are not currently available in this version of the Crystal Ball Developer Kit CB Auto_Open see CB Startup Not Included in This Version 247 CB CloseCB see CB Shutdown CB CloseOverlay CB CopyCertainty CB CopyFore CB CopyOverlay CB CopyRangeMax CB CopyRangeMin CB ForeWindows CB FreezeAssum replaced by CB Freeze CB FreezeAssumND replaced by CB FreezeND CB Help CB OpenOverlay CB OverlayPrefs CB OverlayPrefsND CB RangePrefs CB RangePrefsND CB ResampleFore CB RestoreRun replaced by CB RestoreResults CB RestoreRunND replaced by CB RestoreResultsND CB SaveRun replaced by CB SaveResults CB SaveRunND replaced by CB SaveResultsND CB SelectSome CB SetForeTrial CB SetView CB StatsPrefsND Regarding CB StatsPrefsND the following describes why it was omitted from this version of the Crystal Ball Developer Kit the constants cbStaBaseRange and cbRngDisplay are obsolete since their functionality is replaced by the filtering constants in CB SetFore the constant cbStaCenterOn is obsolete because ranges are now always centered on Median and cbStaReversePercentile is obsolete beca
292. rences getting 172 setting 194 195 run results See simulations running simulations 226 running multiple simulations 229 298 Index L M N OP R S TU VW Runtime example 263 Runtime mode 26 200 S sample OptQuest Developer Kit 276 saving results 201 202 saving simulation results 201 202 scatter charts copying 75 customizing 202 203 selecting assumptions 207 CB forecasts 209 charts 208 decision variables 209 sensitivity charts closing 72 copying 76 customizing 210 opening 189 setting certainty ranges 223 showing the OptQuest wizard 279 simulation results restoring 193 saving 201 202 simulations resetting 191 192 restoring results 193 running 226 running multiple 229 single steps 229 stopping criteria 226 stopping multiple 231 trial number 180 single steps 229 starting Crystal Ball 59 151 214 230 statistics getting CB forecast 167 stopping multiple simulations 231 simulations 226 subroutine 21 support resources 21 system requirements 20 270 A B C D E F T technical support 21 terms 21 training 21 trend charts closing 73 copying 76 customizing 231 232 opening 189 trials 180 trials running one 229 U unloading Crystal Ball 225 user defined event macros 279 user defined macros 26 V values default 26 variables decision attributes 216 decision defining 108 109 decision selecting 209 enumer
293. rences dialog for the selected sensitivity chart either open or closed If more than one sensitivity chart is found opens a chooser dialog If no sensitivity chart has been defined this call creates a new chart with no associated forecast using the default preferences This chart then becomes the selected chart for subsequent sensitivity chart calls If this call is used and a simulation has not been run the macro returns error 5009 CB SensPrefs Example This example runs a simulation with 1000 trials either creates a sensitivity chart selects a single sensitivity chart or opens a chooser dialog if there are multiple sensitivity charts and then opens the Sensitivity Preferences dialog for the selected sensitivity chart CB Simulation 1000 CB SensPrefs CB SensPrefs Related Call Name Description CB SensPrefsND Sets preferences for the specified sensitivity chart without using a dialog CB SensPrefsND The function sets preferences for the selected sensitivity chart without using a dialog If more than one sensitivity chart is open and no chart is selected this call returns a cbErrNoSelection error for CB MacroResult Table 155 Parameters for CB SensPrefsND Parameter VBA Data Type Value Description Index Integer See Table 156 Works with optional parameters Value1 and Value2 to set sensitivity chart preferences 210 Crystal Ball Macro Calls Parameter VBA Data Type Value Description Valuel
294. riable name in quotes Specifies the new decision variable name For Index 2 cbDecMin Double Any number Sets the new minimum lower bound For Index 3 cbDecMax Double Any number Sets the new maximum upper bound For Index 4 cbDecType Integer cbDecVarTypeContinuous 0 cbDecVarTypeDiscrete 1 cbDecVarTypeBinary 2 cbDecVarTypeCategory 3 cbDecVarTypeCustom 4 For a detailed description of each of these cbDecType settings see CB DefineDecVarND on page 109 For cbDecVarTypeCustom a string of data must be supplied with Index coDecCustomData 7 For Index 5 cbDecStep Double Any whole number smaller than the range and greater than 0 Sets the new step size for discrete variables For Index 6 cbDecFrozen Boolean True or False True freezes the current decision variable False unfreezes it if frozen For Index 7 coDecCustomData String A list of at least two values separated by commas ora reference to a range of cells containing these values decimal values can be used The range must be one dimensional adjoining cells in one row or one column Supplies a list of data for coDecType cbDecVarTypeCustom 4 CB SetDecVar Example 1 This example changes the lower bound of the decision variable in cell B4 to 0 CB SetDecVar Range B4 2 O CB SetDecVar Example 2 This example changes the type of the decision variable in
295. rt is produced the same as checking Show All Goodness of Fit statistics on the Output Options panel of the wizard if set to True all statistics appear For Index 23 cbBftFitDistLockParam The name of a lockable distribution from Table 53 see Description Integer The index number of a lockable distribution from Table 53 see Description Specifies one of the following distributions whose parameters are locked The following distributions from Table 53 can be used as Valuel parameters e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use value2 to specify the number of the target parameter CB BatchFitND 51 Related Value For Index 24 cbBftFitDistLockParamCl ear Named Constant Value The name of a lockable distribution from Table 53 see Description VBA Data Type Integer Index Value The index number of a lockable distribution from Table 53 see Description Description Specifies one of the following distributions whose parameters are cleared The following distributions from Table 53 can be used as Value1 parameters e Gamma distribution Location Shape parame
296. rtOnObsolete Example ados n ee erat ud 44 CB AlertOnObsolete Related Calls rar eee seed seeess eeu tees A 44 CBAssumPreisND 24s s5e0090 PP EE ITSE A 44 CB AssumPrefsND Example du ds bes e saws eer er ee CREMA L d asco Yd RR ER DO CR REC TE SA RU bcd be x Pd ER 45 CAR Example doc ok OCC d ORO CR e eR DIO CR d RAR 45 CI AmoDow shilt Example 2 2 225223 2a eis ceandesieeave RR ORE ACE RON 46 CUBA sao 46 COIN EA Sed dps A AAA A 46 CB BatchFit Related Calls A A EE EET 46 CB BatchPitND ewe or er ates burs ves 46 CAMPS EXAM ici AD a dic e CB BatchFitND Example 2 A Pe eee es ree eee Tee ree 39 CB BatchFitND Related Calls ee ads Rs Rd M ead vas ads qe Wn UC vr OB DUgULtrap COMES Sed peau TERREA CERA EA HERE MERE A Xd ERE S par d qt Ch Bootstrap Related Calls aid A REdioa qe 56 CB BootstrapND T re eres TE as aw I T se S CD Boota D Epi ciar ida ARA ed s59 CB BootstrapND Example 2 E a 59 CB BootstrapND Related Calls ids M or ste D9 4 Xe ASA CODES TRENDS 4 252444 HERR Xa pda e dad bpaqe wide pq s dd v 60 CB CBLoaded Related Calls SEEEN A d quies didqqu 60 CE CellPrels essc ee das bas bas ees ates bas 244 sse GO CB CellPreis Example oss nya eee Tee rere Pe 60 CB CellPrefs Related Calls TT errem 60 CB CellPref
297. rtain absolute value threshold are correlated True if True use cbBftOutputCorrelationThreshold 26 to return the threshold value cbBftLinkToCorrelationMatrix 16 Returns a boolean to indicate whether there is a link to the matrix of correlations between the data series True assuming CB GetBatchFitOption 145 Named Constant Value Index Value Description cbBftOutputCorrelationMatrix 14 is set to True cbBftOutputGoodnessOfFitReport 17 Returns a boolean to indicate whether a goodness of fit report is produced True if True use cbBftOutputGoodnessOfFitSheet 27 to return the sheet name of the report cbBftOutputAssumReport 18 Returns a boolean to indicate whether an assumption report is produced True if True use cbBftOutputAssumSheet 28 to return the sheet name of the report cbBftOutputAssumFullStatistics 19 If cbBftOutputAssumReport 18 is True can be used to return a boolean to indicate whether the assumption report includes full statistics True cbBftUseDistLocking 21 Returns a boolean to indicate whether parameter locking is switched on True cbBftOutputGoodnessOfFitAllStats 22 Returns a boolean to indicate whether all statistics should appear when a Goodness of Fit report is produced True cbBftFitDistLockParam 23 Returns the locked value of the specified distribution and parameter The following distributions from Table
298. s the current setting for forecast chart window display options cbTwoDOutputOption Used with va1ue1 to get output report options cbTwoDPercent Used with va1ue1 to return current percentile settings optionally you can supply a Microsoft Excel range to fill with percentile values CB GetTwoDSimulationOption 173 Value or Named Constant cbTwoDMSDOption Index Description Returns the maximum number of uncertainty simulations to display in the output report and overlay chart Table 131 CB GetTwoDSimulationOption Value1 Parameter Optional Integer Related Value Value or Named Constant Index Description For Index 2 cbTwoDGetUncerainty 1 Used with cbTwoDGetAssum to cbTwoDGetAssum Integer enumerate the list of selected uncertainty assumptions For Index 2 cbTwoDGetVariability 2 Used with cbTwoDGetAssum to cbTwoDGetAssum Integer enumerate the list of selected variability assumptions For Index 3 cbTwoDOuterSim Positive whole number integer n a Used with Trials cbTwoDOuterSimrTrials to indicate the number of trials in the outer uncertainty simulation For Index 4 cbTwoDInnerSim Positive whole number integer n a Used with cbTwoDInnerSimTrials Trials to indicate the number of trials in the inner variability simulation For Index 5 cbTwoDShowDefineFore 1 Returned to indicate that all cbTwoDForeOption Integer defined forecasts are displa
299. s blank until one or more forecasts are added with the appropriate CB TrendPrefsND call If more than one chart is found but one is not selected a chooser dialog appears Note This call is included for compatibility with Crystal Ball 2000 x 5 x However it differs somewhat from earlier versions For details see CB OpenTrend on page 258 To open a chart of a specific type by its chart ID use CB OpenChart CB OpenChart on page 186 CB OpenSensitiv 189 CB OpenTrend Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next trend chart in the workbook and then opens it CB Simulation 1000 CB CheckData CB SelectChart cbChtTrend CB EnumChart cbChtTrend CB OpenTrend CB OpenTrend Related Calls Name Description CB CloseTrend Closes the selected trend chart CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB PasteData This subroutine pastes assumption decision or forecast data from ranges specified with CB CopyData and CB CopyDataND This subroutine together with CB CopyData and CB CopyDataND helps you to quickly set up rows or columns of assumptions with similar distribution types or decision variables with similar bounds The worksheet must be active for Crystal Ball to run this command Assumption and decision variable data can be pasted into simp
300. s example subroutine checkresult checks the last Crystal Ball macro call It uses the CB MacroResult return value to check the status of the last call and display the appropriate message Sub checkresult Select Case CB MacroResult case cbErrNone MsgBox Completed OK case cbErrBadValue MsgBox Bad parameter value case cbErrNoForecastInCell MsgBox No forecast in active cell case cbErrNotReady MsgBox No simulation yet case cbErrNoAssumptionInCell MsgBox Missing assumptions in selected cell s case cbErrBadSelector MsgBox Bad value in parameter case cbErrBadCommand MsgBox Bad value in parameter parm number case cbErrNoCBSheets MsgBox No worksheets with CB information to save case cbErrTooManyAssumptions MsgBox Too many assumptions case cbErrTooManyForecasts MsgBox Too many forecasts case cbErrBadCorrelation MsgBox Invalid correlation s case cbErrBadAssumption MsgBox Invalid assumption parameter s case cbErrCallingDLL MsgBox Could not find the DLL case cbErrUnexpected MsgBox An unexpected error occurred End Select End Sub CB MacroResult Related Call Name Description CB MacroResultDetail Indicates if a macro call worked correctly including detailed error information CB MacroResult 183 CB MacroResultDetail This function returns detailed information about whether other Crystal Ball macro calls worked correctly and can include additional information for compatibility and diagno
301. s expected Table3 CB AlertOnArgumentError Parameter Parameter VBA Data Type Description turnOn boolean True displays an alert message when an argument error occurs False switches off this alert The default is True Crystal Ball Macro Calls CB AlertOnArgumentError Example This example switches off alerts when argument errors occur CB AlertOnArgumentError False CB AlertOnArgumentError Related Calls Name Description CB AlertOnMacroResultError Displays a message when an execution error occurs CB AlertOnObsolete Displays a message when an obsolete call or constant is used CB AlertOnMacroResultError This subroutine displays a message when an error occurs during the execution of a subroutine or function macro Table 4 CB AlertOnMacroResultError Parameter Parameter VBA Data Type Description turnOn boolean True displays an alert message when an error occurs False switches off this alert The default is False CB AlertOnMacroResultError Example This example switches on alerts when macro errors occur CB AlertOnMacroResultError True CB AlertOnMacroResultError Related Calls Name Description CB AlertOnArgumentError Displays a message when an argument error occurs CB AlertOnObsolete Displays a message when an obsolete call or constant is used CB AlertOnObsolete This subroutine displays a message when an obsolete call argument or constant is used in
302. s in the report ata the chart False does not defines the percent scale specified scale of the chart cbRptOptimizerSummary 39 Includes the OptQuest boolean True includes n a Summary section in the the OptQuest summary report following an information False does optimization run not cbRptOptimizerChart 40 Includes the optimization boolean True includes Integer 1 to 200 solution graph in the the chart False does not defines the percent scale report following an of the chart optimization run cbRptOptimizerBestSolut 41 Includes the OptQuest boolean True includes n a ion Best Solution section in the OptQuest best the report following an solution information optimization run False does not cbRptOptimizerConstrain 42 Includes the OptQuest boolean True includes n a ts Constraints section inthe the OptQuest constraints report following an information False does optimization run not cbRptOptimizerDecVars 43 Includes the OptQuest boolean True includes n a Decision Variables the OptQuest decision section in the report variables information following an optimization False does not run cbRptPredictorChart 45 Includes Predictor results boolean True includes Integer 1 to 200 charts for each series in the charts False does defines the percent scale the report following a not of the charts Predictor run cbRptPredictorStatistics 46 Includes the Predictor boolean True includes n a Stat
303. s just one cell use SecondAsm to define a second cell because you cannot correlate a cell with itself If there is an error in specifying the cells to be correlated CB CorrelateND returns cbErrNoAssumptionInCell Ifyou enter a number outside the range 1 0 and 1 0 the subroutine deletes any correlation between the cells See the Oracle Crystal Ball User s Guide for more information on specifying correlations between assumptions CB CorrelateND Example 1 This example correlates cell B5 with F12 with a correlation coefficient of 0 2 Range B5 F12 Select CB CorrelateND 0 2 CB CorrelateND Example 2 This example correlates cell B12 with F5 with a correlation coefficient of 0 6 Range F5 B12 Select Range B12 Activate CB CorrelateND 0 6 CB CorrelateND Example 3 This example correlates cells B5 and B12 with a correlation coefficient of 0 3 Range B5 B12 Select CB CorrelateND 0 3 CB CorrelateND Related Calls Name Description CB DefineAssum Defines or changes assumptions in selected cells using a dialog CB DefineAssumND Defines or changes assumptions in selected cells without using a dialog Crystal Ball Macro Calls CB CreateChart This function creates a new chart of the specified type and returns the chart ID of the new chart Optionally you can specify the name If successful the new chart becomes the selected chart for subsequent chart calls If the chart is not created successf
304. s selected If the chart ID is not specified the currently selected chart is opened If the specified chart is not found a chooser dialog appears No error is returned Currently this call only works on current and not restored results Table 145 CB OpenChart Parameters with Values Parameter VBA Data Type SimChartType Integer 186 Crystal Ball Macro Calls Value cbChtOverlay 1 cbChtScatter 2 cbChtSensitiv 3 cbChtTrend 4 Description Specifies the type of chart you are opening overlay scatter sensitivity or trend using the named Parameter VBA Data Type Value Description constant and index values listed in the Value column ChartID Optional String Chart ID The chart ID returned by CB EnumChart Table 59 entered directly or using CB EnumChart CB OpenChart Example 1 This example opens the specified overlay chart trend chart and sensitivity chart CB OpenChart cbChtOverlay Overlay Chart 1 CB OpenChart cbChtTrend Trend Chart 1 CB OpenChart cbChtSensitiv Sensitivity Chart 1 CB OpenChart Example 2 This example runs a simulation calls CB CheckData because a CB Enum call follows and then opens the next overlay chart in the workbook CB Simulation 1000 CB CheckData CB OpenChart cbChtOverlay CB EnumChart cbChtOverlay CB OpenChart Related Calls Name Description CB CloseAllCharts Closes all open chart windows equivalent to A
305. s to methods settings corresponding to the Predictor Methods panel This class enables you to control which time series and regression methods to use and to set method parameters PredSetup PredOptions This class provides access to Predictor options corresponding to the Predictor Options panel Use this class to specify options such as error measure and forecasting technique PredSetup PredSeries This class provides access to setup information for each series Use this classto manage individual input series information such as series name Excel number format seasonality and cycle regression variable details statistics and access series data values An enumerator property of the PredSetup class Series enables you to access each series by index into the input data range Predictor Results Class Main classes for accessing Predictor results e PredResults main class interface for accessing Predictor results e PredResults PredResultsPreferences e PredResults PredResultsWindow e PredResults PredSeriesResult PredResults This is the top level interface class that provides access to objects that retrieve results available through the Predictor results form This class has properties to access results preferences and to select series and methods This class has a method to paste the forecast results to your model PredResults PredResultsPreferences This class provides access to results preferences such as confidence intervals numbe
306. sND T ee ad pride ads pd S e uud cgaae wd dec ae t qot de oae ED de o de ede ON CB CellPres de a oss 3 raqosexoxdqe eens yavetdesecdQePee papse 63 CB ChP re carpa AA DARA AA dia 63 CRCDBISPIID ESE a RARA AD RARA RA 64 CB ChartPrefs Related Calls NUS e eS REESE TRE aa 64 Pee oS La aac pq E ERE HERE EA RECAP a IC OC Ree or CBA Das PIS ND Example corria rr iaa 67 CB ChartPrefsND Related Calls IIA CM 67 A acies 2843 8 EE ACER ee aa E e EEA es 5 CB CheckData Example aida cia ta AA ia 67 CH CheckData Related Calls acusa AA A A A ROG A 68 CB CheckDataND ee ere eos 68 iw Ne od IRE Tr D Pm 68 CB beckDataND Related Galle iuaqaaceuq up qecreduqpeeebeqd praed edu 69 CB ClearData veas T m Rn re cy 69 E A E E HERES de Ea Ea AAA bce e RE Rad EARS RC EX Rd han 69 CB ClearDataND iscke savas pk RE REX GE RIXA Yd ERR REX RA GEE RR EA YR 70 COREANO a arid ek ae d do aree eC Eu t bue ees 70 LRL ID Relais tll erre eae RRAYC Kd qe TEES ERES EA 70 CB CloseAllChart cocino E iQ eqs d qe did qe ad 70 CB CloseAllCharts Example mews oe TER 70 CD Cisse Ak bass Rebel Lal iua debian dele dU E o RE ER UP E War d CB CloseChart 2oucexskass des A lere ee ee ee eee eT ee 71 CB CloseChart Example eds ss Tl OCIO Related NE errar e ge e ues 71 mee ENTE E
307. simulation CB DecisionTableND Example This example resets the simulation defines cell B5 as the target forecast with cells C1 and C2 as the first and second decision variables Then it specifies the number of test values to use for each of the two decision variables 7 and 10 respectively sets 500 as the maximum number of trials to run and indicates that forecast charts are to be hidden while the simulation is running The final line runs the tool CB ResetND Select a target forecast Range B5 Select CB DecisionTableND cbDecChooseTarget Clear the list of any previously selected decision variables CB DecisionTableND cbDecChooseDecVar cbChdClearList Select decision variables cells C1 and C2 Range C1 Select CB DecisionTableND cbDecChooseDecVar cbChdAdd Range C2 Select CB DecisionTableND cbDecChooseDecVar cbChdAdd Set number of values to test for DecVarl in cell C1 CB DecisionTableND cbDecSimOption cbDecNumValuesVar1 7 98 Crystal Ball Macro Calls Set number of values to test for DecVar2 in cell C2 CB DecisionTableND cbDecSimOption cbDecNumValuesVar2 Set maximum number of trials per simulation CB DecisionTableND cbDecSimOption cbDecSimTrials Hide forecast chart windows during simulation CB DecisionTableND cbDecForeOption cbDecHideFore Run the Decision Table tool CB DecisionTableND cbDecRun CB Decision
308. sisDatalnRows 1 cbDataAnalysisDatalnColumns 2 cbDataAnalysisSelectHeaders Integer Returns a boolean value to indicate if column header text is in the selection True cbDataAnalysisSelectLabels Integer Returns a boolean value to indicate if row label text is in the selection True cbDataAnalysisSelectLSL 154 Crystal Ball Macro Calls Integer Returns the range of values selected as forecast LSLs lower specification limit for process Named Constant Value VBA Data Type Index Value Description capability analysis The range is a string in the format workbook sheet A 1 cbDataAnalysisSelectUSL Integer Returns the range of values selected as forecast USLs upper specification limit for process capability analysis The range is a string in the format workbook sheet A 1 cbDataAnalysisSelectTarget Integer Returns the range of values selected as forecast Targets for process capability analysis The range is a string in the format workbook sheet A 1 cbDataAnalysisAutoOpenCharts Integer Returns a boolean value to indicate whether to open forecast charts automatically when the data analysis runs True cbDataAnalysisSetViewType Integer 10 If charts are shown returns cbChtChartType constants from CB ChartPrefsND to indicate which chart view appears See Table 24 for returned constants cbDataAnalysisFitToDi
309. stMean Boolean changes the cell value to the mean False leaves the existing values in the cells 62 Crystal Ball Macro Calls Used With Specified Named Constant or Values of Index2 boolean Value Index Value Description For Index2 4 True or False n a For decision variable cells cbCelRangeMidpoint True changes the cell value Boolean to the midpoint False leaves the existing values in the cells For Index2 5 True or False n a For assumption cells True cbCelDistMedian Boolean changes the cell value to the median False leaves the existing values in the cells For Index2 6 True or False n a For decision variable cells cbCelRangeMin Boolean True changes the cell value to the range minimum False leaves the existing values in the cells For Index2 7 True or False n a For decision variable cells cbCelRangeMax Boolean True changes the cell value to the range maximum False leaves the existing values in the cells CB CellPrefsND Example This example changes cell preferences for assumption cells including both existing and future assumptions It turns off any pattern changes the color to cyan and displays assumption cell notes CB CellPrefsND cbCelAssum cbCelPattern 0 False CB CellPrefsND cbCelAssum cbCelColor 8 False CB CellPrefsND cbCelAssum cbCelNote True False CB CellPrefsND Related Calls Name Description CB CellPrefs Displays the Cell Pre
310. stal Ball report from the creates a report from the current simulation and restored results optimization or time series forecast using a dialog 130 Crystal Ball Macro Calls Name Description CB CreateRptND Creates a Crystal Ball report from the creates a report from the current simulation and restored results optimization or time series forecast without a dialog CB ExtractData Extracts data from the current simulation and restored results optimization or time series forecast using a dialog CB Fit This function fits a specific probability distribution to a set of data range of cells and returns information about the fit Table 74 CB Fit Returned Data Type Returned Value Returned Data Type The goodness of fit statistic for the fit of the data to the selected distribution Variant You select the distribution to fit to your data among the possible distributions listed below and the statistic to return CB Fit must be used with CB SetFitRange CB SetFitRange on page 219 as shown in the examples for this call Note You cannot fit to distributions that are not listed Table 75 CB Fit Parameters Parameter VBA Data Type Value Description Dist Integer See Table 76 Used to specify the distribution to use for fitting Values are listed in Table 76 Criterion Integer See Table 77 Used to specify which fitting statistics to return Values appear in Table 77 pValue Opti
311. stant Value Index Value Description cbTrdTitle 1 Gives the trend chart a title as defined by Value1 cbTrdChooseFore 2 Clears and selects the forecasts for the trend chart according to va1ue1 cbTrdVertGridLines 4 Turns on and off the vertical grid lines according to Valuel cbTrdHorzGridLines 5 Turns on and off the horizontal grid lines according to va1ue1 cbTrdChartType 6 Sets the trend chart type according to Valuel cbTrdValueAxis 7 Sets options for the value axis according to Valuel cbTrdCertaintyBands 8 Sets up to 7 certainty bands to display according to Value1 through Value7 Note Index cbTrdForeTitleAxis 3 is now obsolete Table 183 following describes the Va1ue1 parameter Table 183 CB TrendPrefsND Value1 Parameter Values Required Variant Used With Specified Values of Named Constant or Other Index Value Index Value Description For Index 1 String Title in quotes n a Defines the trend chart title For Index 2 Integer cbChfAdd 4 Adds the forecast in the selected cell to the list of chosen forecasts For Index 2 Integer cbChfClearList 5 Clears the list of chosen forecasts CB TrendPrefsND 233 Used With Specified Values of Named Constant or Other Index Value Index Value Description For Index 4 Boolean True or False n a True turns on vertical grid lines False turns them off For Index 5 Boolean True or False n a True turns
312. stic purposes Table 142 CB MacroResultDetail Returned Data Type Returned Value Returned Data Type The value of the specified property of CBMacroResultType as indicated below Variant CB MacroResultDetail is different from other Developer Kit subroutines and functions because its parameters are properties ofa type class instead of constants See the example for appropriate syntax Table 143 CB MacroResultDetail Properties Property VBA Data Type Description OldValue Integer The value returned by CB MacroResult listed in Table 144 NewValue Integer The value returned by CB MacroResultDetail NewValue in this version of Crystal Ball Msg String A string that summarizes the error MsgDetails String A message with more information about the error MsgTitle String The command for which these results are returned DialogResult String Non localized strings describing the actions in a dialog Yes No OK Cancel and None None indicates that no dialog appeared ElapsedTimeInMS Long The time in milliseconds required to process the command To see a list of the named constants and values returned by CB MacroResultDetail NewValue open Crystal Ball online help and find Crystal Ball Error Messages in the Contents In VBA subroutines and functions you can check the returned value against either the named constants or values Table 144 Values Returned by CB MacroResult or CB MacroResult
313. stribution Integer 11 Returns a boolean value to indicate whether forecast charts should be fitted to a distribution True cbDataAnalysisRankingMethod Integer 12 Returns the ranking method for distribution fitting See Table 77 for constants cbDataAnalysisGenerateCorrela tionMatrix Integer 13 Returns a boolean value to indicate whether rank correlations between forecast charts should be displayed in a matrix True cbDataAnalysisRunOnAllModels Integer 14 Returns a boolean value to indicate whether a simulation is run on all open workbooks at the same time the selected data is analyzed True cbDataAnalysisNumberOfSeries Integer 15 Returns an integer value equal to the number of currently selected data series CB GetDataAnalysisOption 155 Named Constant Value VBA Data Type Index Value Description cbDataAnalysisNumberOfPoints Integer 16 Returns an integer value equal to the number of points in each data series CB GetDataAnalysisOption Example 1 The following example returns a string with the address of the selected data range CB GetDataAnalysisOption cbDataAnalysisSelectData CB GetDataAnalysisOption Example 2 The following example returns the current view setting for forecast charts generated by the Data Analysis tool CB GetDataAnalysisOption cbDataAnalysisSetViewType CB GetDataAnalysisOption Related Calls Name
314. t symbol according to Value cbScatterPointSize 10 Specifies the size of scatter points in pixels 1 30 cbScatterPointColor 11 Specifies the scatter point color 0 15 as defined in the Chart Preferences dialog Chart Type tab O Auto cbScatterDrawLines 12 If True displays a fit line on the scatter chart if False lines do not appear cbScatterLineWidth 13 Specifies the scatter line width in pixels 1 10 cbScatterLineType 14 Specifies the type of scatter line according to Value cbScatterLineColor 15 Specifies the scatter line color 0 15 as defined in the Chart Preferences dialog Chart Type tab O Auto cbScatterCriteriaLimit 16 Specifes the scatter chart criteria to use according to Value cbScatterCriteriaLimitNumber 17 Defines the number of trials to appear taken into account only if cbScatterCriteriaLimit LimitTrialNumber Value cbScatterCriteriaLimitPercentage 18 Defines the percentage of trials to show taken into account only if cbScatterCriteriaLimit LimitTrialPercentage Value with a possible range of 1 100 204 Crystal Ball Macro Calls Named Constant Value Index Value cbScatterDrawCorrelationCoefficient 19 Description IfTrue displays a correlation coefficient for each plot if False does not display the correlation cbScatterShowFilteredOutValues 20 If True displays filtered out values
315. tOption cbBftInputRange CB GetBatchFitOption Example 2 This example returns the locked value for parameter 3 Location for the lognormal distribution CB GetBatchFitOption cbBftFitl CB GetBatchFitOption Related Calls Name Description CB BatchFit Launches the Batch Fit tool CB BatchFitND Runs the Batch Fit tool without displaying dialogs CB GetBootstrapOption DistLockParam cbDfaLogNormal 3 This function returns specified settings made by CB BootstrapND or the Bootstrap tool Table 93 CB GetBootstrapOption Returned Data Type Returned Value The specified Bootstrap settings Variant Returned Data Type Table 94 CB GetBootstrapOption Parameters Parameter Index Required Required VBA Data Type Integer Table Table 95 148 Crystal Ball Macro Calls Parameter Required VBA Data Type Table Index2 Optional Integer Table 96 Value Optional Variant Table 97 Table 95 CB GetBootstrapOption Index Parameter Required Integer Named Constant Value Index Value Description cbBtsGetTarget 1 Returns a string with the address of the target forecast in the format workbook sheet A 1 cbBtsGetDataRange 2 Returns a string with the address of the selected bootstrap data range in the format workbook sheet A 1 Z 100 cbBtsMethod 3 Returns the constant of the selected bootstrap method cbBtsMethodResample 1 or coBtsMeth
316. taND Example This example copies only the Crystal Ball assumption data from cells B5 and B6 Range B5 B6 Select contains an assumption and a forecast CB CopyDataND cbCelAssum CB CopyDataND Related Calls Name Description CB CopyData Copies Crystal Ball data in specified range CB PasteData Pastes assumptions decision variables or forecasts into selected cells CB CopyScatter This call copies the selected scatter chart to the clipboard If more than one chart is found but one is not selected a chooser dialog appears CB CopyScatter Example This example runs a simulation calls CB CheckData because a CB Enum call follows selects the next scatter chart in the workbook and then copies it CB Simulation 1000 CB CheckData CB SelectChart cbChtScatter CB EnumChart cbChtScatter CB CopyScatter CB CopyScatter 75 CB CopyScatter Related Calls Name Description CB CloseChart Closes the selected chart of the given type CB EnumChart Returns the unique name of the next chart of the specified type CB OpenChart Opens the selected chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB CopySensitiv This call copies the selected sensitivity chart to the clipboard If more than one chart is found but one is not selected a chooser dialog appears CB CopySensitiv Example This example runs a simulation calls CB CheckData because a C
317. tal Ball 7 2 1 For more information on these constants and other changes see Table 66 To support the rewritten version of OptQuest added in version 11 1 1 0 00 o The following Index constants are added cbExtDataOptimizerType 14 cbExtChooseDecVar 15 o The following Value constants are added for cbExtDataOptimizerType cbDatOptimizerSolutions 1 cbDatOptimizerStatistics 2 o The following Value constants are added for cbExtChooseDecVar cbChooseDecVarAll 1 cbChooseDecVarChosen 2 cbChooseDecVarAdd 3 cbChooseDecVarClearList 4 To support the rewritten version of Predictor added in version 11 1 1 3 00 the following Index constants are added cbExtPredictorResultsSheetName 17 cbExtPredictorMethodsSheetName 18 cbExtPredictorResultsHistorical 19 cbExtPredictorResultsFitted 20 cbExtPredictorResultsForecast 21 cbExtPredictorResultsConfidence 22 cbExtPredictorResultsResiduals 23 cbExtPredictorMethodsErrors 24 coExtPredictorMethodsStatistics 25 cbExtPredictorMethodsParameters 26 and cbExtPredictorMethodsRanking 27 CB Fit CB Fit must now be used with CB SetFitRange to select the range of data to fit to a distribution Constants have been added to support distributions added in Crystal Ball 7 cbDfaMinExtreme 18 cbDfaMaxExtreme 19 cbDfaStudentsT 20 and cbDfaBetaPert 23 added in Crystal Ball 7 3 Constant cbDfaExtremeValue 15 is deprecated It is included for Crystal Ball 200
318. tal Ball forecasts for further analysis Note Before calling CB DataAnalysis reset the simulation CB DataAnalysis Example This example resets the Crystal Ball simulation and opens the Data Analysis wizard CB ResetND CB DataAnalysis CB DataAnalysis Related Calls Name CB GetDataAnalysisOption Description Returns current settings for the Data Analysis tool CB DataAnalysisND Imports data into Crystal Ball forecasts without using a dialog CB DataAnalysis ND The Data Analysis tool imports data directly into Crystal Ball forecasts for further analysis This call runs the Data Analysis tool and displays results without using a dialog Note Before calling CB DataAnalysisND reset the Crystal Ball simulation Table 42 CB DataAnalysisND Parameters Parameter Required VBA Data Type Table Index Required Integer Table 43 Value Optional Variant Table 44 Table 43 CB DataAnalysisND Index Parameter Required Integer Named Constant Value VBA Data Type Index Value Description cbDataAnalysisRun Integer 1 Runs the Data Analysis tool when all settings are complete cbDataAnalysisSelectData Integer 2 Selects the numeric portion of the data to be imported The range can either be specified as a separate line preceding the CB DataAnalysis 91 Named Constant Value VBA Data Type Index Value Description CB DataAnalysisND call such as A1 C100 Select or it can be th
319. te CB Com Devkit chm on page 274 describes a reference help file that summarizes all the OptQuest and Predictor Developer Kit objects and shows the hierarchy of the development system When you first open CB Com Devkit chm three namespaces appear in the navigation pane Figure 1 These namespaces are only used in C code not Visual Basic VBA code However if you are using VBA they indicate which classes are used for OptQuest automation Optimization and which are used for Predictor Predictor When writing VBA code you omit Optimization or Predictor as shown in the code examples included in this Developer s Guide Important Predictor Classes Two categories of important classes in the Predictor Developer Kit e Predictor Setup Class on page 288 e Predictor Results Class on page 289 Developer Kit Use and Structure 287 Other classes support those two areas of functionalilty For lists and descriptions of methods and properties in Predictor namespace classes open CB Com Devkit chm in the Docs folder beneath the main Crystal Ball installation folder by default C Program Files Oracle Crystal Ball You can use this file as a reference at any time For more information on this help system and how to use it see CB Com Devkit chm on page 274 If you select a class in the navigation pane its structure is outlined in the right pane with annotations Click any underlined link to learn more about that object
320. terms Crystal Ball uses to define the confidence interval around the stopping criterion 0 relative 1 absolute cbForPrecisionAbsoluteValue Returns the size of the confidence interval in absolute forecast units cbForPrecisionRelative Value Returns the size of the confidence interval in relative percentage terms cbForPrecisionMean 10 Returns whether Crystal Ball uses the precision of the mean as a simulation stopping criterion 0 no 1 yes cbForPrecisionStdDev 11 Returns whether Crystal Ball uses the precision of the standard deviation as a stopping criterion for the simulation 0 no 1 yes cbForPrecisionPerc 12 Returns whether Crystal Ball uses the precision of a percentile value as a stopping criterion for the simulation 0 no 1 yes CB GetFore 163 Named Constant Value Index Value Description cbForPrecisionPercValue 13 Returns the percentile value used to check for the indicated precision cbForFilter 14 Returns whether Crystal Ball uses forecast filtering O no 1 yes cbForFilterlnside 15 Returns which forecast values Crystal Ball discards in filtering O the values outside the filtering range 1 the values inside the range cbForFilterFrom 16 Returns the lower bound of the filtering range cbForFilterTo 17 Returns the upper bound of the filtering range cbForFilterGlobal 18 Returns whether global filtering is set for the forecast
321. ters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e Binomial distribution Trials parameter e Hypergeometric distribution Trials parameter Use value2 to specify the number of the target parameter Table 12 CB BatchFitND Value2 Parameter Optional Variant Related Value For Index 12 cbBftOutputLocation Named Constant Value True or False VBA Data Type boolean Index Value n a Description Used with Valuel cbBftNewWorkbook or cbBftNewWorksheet to indicate whether the output goes in a new workbook or worksheet If cbBftNewWorksheet is set to False Value3 can be used to indicate the upper left cell of the output range on the current worksheet Otherwise cell A1 is assumed For Index 15 cbBftOutputCorrelation 52 Crystal Ball Macro Calls A whole number or decimal between O and 1 inclusive Double n a Used with Valuel True to indicate that assumptions should be correlated if the absolute value of their correlation Related Value Named Constant Value VBA Data Type Index Value Description is equal to or greaterthan the specified threshold For Index 17 cbBftOutputGoodnessOf FitReport Astring that indicates the report name String n a Used with Valuel True to specify a report name stri
322. terval in forecast units according to Value cbForPrecisionRelativeValue 9 Sets the size of the confidence interval in percentage terms according to Value cbForPrecisionMean 10 Sets whether Crystal Ball uses the precision of the mean as a stopping criterion according to Value cbForPrecisionStdDev 11 Sets whether Crystal Ball uses the precision ofthe standard deviation as 220 Crystal Ball Macro Calls Named Constant Value Index Value Description a stopping criterion according to Value cbForPrecisionPerc 12 Sets whether Crystal Ball uses the precision of a percentile value as a stopping criterion according to Value cbForPrecisionPercValue 13 Sets the percentile value that Crystal Ball checks for the indicated precision according to Value cbForFilter 14 Sets whether Crystal Ball filters forecast values according to Value cbForFilterlnside 15 Sets whether discards forecast values inside or outside the indicated range according to Value cbForFilterFrom 16 Sets the lower bound of the filtering range according to Value cbForFilterTo 17 Sets the upper bound of the filtering range according to Value cbForFilterGlobal 18 Specifies whether Crystal Ball applies the filtering options to equivalent trials of all forecasts according to Value cbForFrozen 19 Freezes the forecast according to Value cbForLSL 20 Enters a lower specification limit for the forecast according to
323. th cbExtExistingSheet Table 71 Value Parameter Values that Support Index Constant cbExtStartSheet Named Constant Value Index Value Description cbExtNewWorkbook 1 Extracts the results to a new workbook using the cbExtSheetName value as the name of the sheet cbExtCurrentWorkbook_NewSheet 2 Extracts the results to the current workbook using the cbExtSheetName value as the name of the sheet cbExtCurrentWorkbook_ 3 Extracts the results to the current CurrentSheet workbook s current sheet The following values are used with Index cbExtDataOptimizerType to specify which optimizer data should be extracted to the specified location A third boolean value True or False is used to activate or deactivate the preceding entries Table 72 Value Parameter Values for Index Constant cbExtDataOptimizerType Named Constant Value Index Value Description cbDatOptimizerSolutions 1 Extracts OptQuest solution information cbDatOptimizerStatistics 2 Extracts OptQuest statistical information The following values are used with Index cbExtChooseDecVar to specify decision variable data for extraction If not specified the current setting from the Extract Data dialog is used CB ExtractDataND 129 Table 73 Value Parameter Values that Support Index Constant cbExtChooseDecVar Named Constant Value Index Value Description cbChooseDecVarAll 1 Includes all decision variables cbChooseDecVarChosen 2 Includes ch
324. th a Value entry to Integer specify the number of bootstrap samples to use For Index 6 cbBtsSample cbBtsTrialsPerSample 2 Used with a Value entry to Integer specify the number of trials to run for each bootstrap sample For Index 7 cbBtsShowDefinedFore 1 Uses display settings for each cbBtsForeOption Integer forecast chart the equivalent of the Show Forecasts As Defined dialog setting For Index 7 cbBtsShowTargetFore 2 Shows only the target forecast cbBtsForeOption Integer the equivalent of the Show Only Target Forecast dialog setting For Index 7 cbBtsHideFore 3 Hides all forecasts the cbBtsForeOption Integer equivalent of the Hide All Forecasts dialog setting Table 17 CB BootstrapND Value Parameter Optional Variant Related Value Named Constant Value VBA Data Type Index Value Description For Index2 A string containing an String n a Specifies custom cbBtsPercentCustom Excel range that holds percentile values to desired percentile analyze values The values must be entered into Excel as numbers not formatted as percentages can be decimals For Index2 A positive whole number Integer n a Number of bootstrap cbBtsNumberSamples samples to use For Index2 A positive whole number Long Integer n a Number of trials to run for cbBtsTrialsPerSample each bootstrap sample 58 Crystal Ball Macro Calls CB BootstrapND Example 1 This example resets the Crystal Ball simulation selects a target forecast in cell A1 sp
325. than population 0 and less than 1000 cbDfaMinExtreme 18 likeliest scale greater than n a n a C 0 cbDfaMaxExtreme 19 likeliest scale greater than n a n a C 0 cbDfaStudentsT C 20 midpoint scale greater than degrees of freedom n a 0 integer between 1 and 30 inclusive cbDfaYesNo D 21 probability n a n a n a cbDfaDiscreteUnifor 22 minimum integer maximum integer n a n a m D cbDfaBetaPert C 23 minimum likeliest maximum n a Note cbDfaHypergeometric is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaHypergeometricSuccess in later versions of Crystal Ball cbDfaExtremeValue is deprecated It is included for Crystal Ball 2000 5 5 5 compatibility and is replaced by cbDfaMinExtreme and cbDfaMaxExtreme in later versions of Crystal Ball To define an assumption parameter with a dynamic cell reference specify the cell reference as a string See the Oracle Crystal Ball User s Guide for more information on distribution types and parameters 106 Crystal Ball Macro Calls The active cell must contain a numerical value or be blank If it contains anything other than a numerical value such as an expression a cell reference or text CB MacroResult returns cbErrBadAssumption The parameters must agree with the specified distribution Ifthere is a problem with a parameter CB MacroResult returns cbErrBadAssumption Note Calling this function is not the same thing
326. the appropriate password Click OK In Excel select File then Save As In Save As Type select Microsoft Excel Add In xla the last item Enter the name under which the add in is to be saved Click Save Using Developer Kit Macro Calls in User defined Macros The Oracle Crystal Ball User s Guide describes how to set up and call user defined macros from Crystal Ball workbooks Note that none of the Developer Kit macro calls can be used within user defined macros such as CBBeforeSimulation For more information on user defined macros see relevant sections at the end of Chapter 5 in the Oracle Crystal Ball User s Guide A Note About Defaults and Write Protection Unless otherwise specified defaults are pulled from the user s preference files These defaults can be set through Crystal Ball s preference dialogs or preferences macro calls such as CB RunPrefsND in the Crystal Ball Developer Kit Caution Commands that change Crystal Ball data cells will not run if the cell or the entire worksheet is write protected For example two such commands are CB Simulation and CB CellPrefsND You can use CB WorksheetProtection to unprotect and reprotect worksheets so certain commands such as CB Simulation will run For more information on CB WorksheetProtection see CB WorksheetProtection on page 241 Putting Custom Applications into Runtime Mode If you ever want to deliver an application to someone who has Crystal Ball but is not a ski
327. the constraint will work as intended If you check the Do not show box you won t need to respond to the message again while you are using that particular model Global Macros If you want to run certain event macros with any or all of your Crystal Ball Decision Optimizer models you need to make sure that the workbook containing those event macros is open in Excel User defined Event Macros for Optimizations 283 284 Using the OptQuest Developer Kit Using the Predictor Developer Kit In This Appendix About the Predictor Developer A o e AME REN AUR 285 Devclopor EUA SUUM ioca nu sas datosata a OE 286 Developing Time Senes Forecasting Code 1 23 arreter ter Bien dd curd Febre ERAT S HE UE 290 About the Predictor Developer Kit Note The Predictor Developer Kit described in this Developer s Guide is completely rewritten Developer kit code written for automating CB Predictor in Crystal Ball versions earlier than 11 1 1 3 00 is not compatible with the current version of Predictor or this Predictor Developer Kit Welcome to the Predictor Developer Kit for all Crystal Ball products You can use the Predictor Developer Kit to automate and control the setup and running of Predictor time series forecasts from within applications written for a variety of Microsoft COM compatible platforms This opens up a range of possibilities e Integrating Predictor with other software tools e Creating turnkey applications that shield users fr
328. the list along with any others added previously selects cell C5 and then adds it to the list of frozen cells Then the last line sets this list to be the list of cells to freeze during any simulations Cell C5 is the only cell included in the final list CB ResetND Range B6 Select CB FreezeND cbFrzAddCell Range B7 Select CB FreezeND cbFrzAddCell CB FreezeND cbFrzClearList Range C5 Select CB FreezeND cbFrzAddCell CB FreezeND cbFrzSetList True CB FreezeND Related Calls Name Description CB Freeze Defines which assumptions decision variables or forecasts to hold to their worksheet values during a simulation using a dialog CB Reset Resets a simulation after confirmation prompting CB ResetND Resets a simulation without confirmation prompting CB GetAssum This function retrieves information for a specific assumption cell You can call this function from either a subroutine or a worksheet Note To call this function from a worksheet use the name CB GetAssumFN Named constants do not work as arguments in worksheets You must use the index number instead Note that the CB GetAssum call is not retrieving the name and value of the third and fourth parameters properly for assumptions defined with alternate parameter sets ofa beta distribution via CB DefineAltParms 140 Crystal Ball Macro Calls For best results call CB CheckData before calling this function to ensure the latest data va
329. ther or not to run user defined macros according to Valuel cbRunCapMetrics 52 Sets whether the UI should display capability metric related information according to Valuel cbRunCapMetricsShort 53 Determines if the underlying forecast data should be considered short or long term according to valuel cbRunCapMetricsShift 54 Sets the shift value used for calculating Zst and Zlt according to Valuel cbRunCapMetricsCalcType 55 Determines if the metrics should be calculated from the fitted curve or the data according to va1ue1 cbRunCapMetricsNormalityThresh 56 Specifies the p value threshold used for normality testing according to Valuel cbRunCapMetricsNormalCalcOption S 57 Specifies whether to calculate the data from the fitted curve or the data if the forecast values are not normal according to Va1ue1 only valid if cbRunCapMetricsCalcType O Note The following Index constants used in Crystal Ball 2000 5 5 5 are now obsolete cbRunBurstMode 5 cbRunResetToOriginal 6 cbRunSensitivAnalysis 9 cbRunRetainUnsortedTrials 11 cbRunMacroBeforeSimul 21 cbRunMacroBeforeRecalc 22 cbRunMacroAfterRecalc 23 cbRunMacroAfterSimul 24 cbRunParadiseServer 30 cbRunBurstAmount 33 cbRunPrecisionWithin 45 cbRunPrecisionMean 41 used in versions before Crystal Ball 2000 5 5 5 is now obsolete In Crystal Ball 2000 5 5 5 values for cbRunMode 29 were b
330. tically Launch Crystal Ball When Excel Starts e Open the Excel COM Add ins dialog and check or uncheck Crystal Ball e Include the CB SetCBAutoLoad call CB SetCBAutoLoad on page 214 in Visual Basic or VBA code with the autoLoad parameter set to True or False Whichever alternative you use the same setting appears in both of the other two alternatives For more information on these alternatives see Starting Crystal Ball in the current Oracle Crystal Ball Installation and Licensing Guide CB GetCBAutoLoad returns the current autoload setting True if Crystal Ball is set to automatically load each time Excel opens or False if Crystal Ball is not set to autoload Table 98 CB GetCBAutoLoad Returned Data Type Returned Value Returned Data Type The current autoload setting boolean CB GetCBAutoLoad Example To retrieve the current Crystal Ball autoload setting use this call in a function in the following form ReturnValue CB GetCBAutoLoad CB GetCBAutoLoad Related Calls Name Description CB CBLoaded Indicates whether Crystal Ball is currently loaded within Excel CB SetCBAutoLoad Sets or cancels autoloading with Excel determines whether Crystal Ball is set to open whenever Excel opens CB Shutdown Closes Crystal Ball while leaving Excel open CB Startup Loads Crystal Ball into Excel if possible and indicates when Crystal Ball has been successfully opened CB GetCertainty This fun
331. timizer You can use the OptQuest Developer Kit to automate and control the setup and running of OptQuest optimizations from within programs written for a variety of Microsoft COM compatible platforms This opens up a range of possibilities e Integrating OptQuest with other software tools e Creating turnkey applications that shield users from program intricacies e Building custom reports or automating post optimization analysis e Setting up specialized optimization environments The OptQuest Developer Kit provides a link between OptQuest and your program It consists of a number of object oriented development classes that control many aspects of OptQuest Each copy of Crystal Ball Decision Optimizer comes enabled to use the OptQuest Developer Kit so that programs you develop today can be run by other users with appropriate licenses The OptQuest Developer Kit provides a framework of classes that you can use with OptQuest to perform optimizations Itisa COM Component Object Model object which allows the use of older languages that support ActiveX objects such as Visual Basic 6 0 VB6 C VBA and others Who Should Use This Kit The OptQuest Developer Kit is appropriate for advanced users who want to automate repetitive spreadsheet optimization processes This book assumes that readers are familiar with a COM compatible development platform and Crystal Ball with OptQuest About the OptQuest Developer Kit 269 What This Kit Includes
332. tor Developer Kit Runtime Example Workbook Crystal Ball includes Runtime Example xls a very basic application written in VBA using the Crystal Ball Developer Kit to show how UI controls in this case buttons can be created to Introduction 263 operate a Crystal Ball Runtime application You can open this example in the Examples folder under the folder where Crystal Ball is installed Delivering Crystal Ball Runtime Applications An appropriate Crystal Ball license must be purchased for each person who will use your custom application Typically Crystal Ball Runtime applications are delivered as xls or xla files These are then combined for example zipped with the Crystal Ball setup file for the version of Crystal Ball used to develop the Runtime application for delivery to application users You also need to include an installation script to run the setup file and a licensing script to pass the appropriate license serial number to the Crystal Ball License Manager Alternately you can have application users unzip the application and Crystal Ball setup file double click the setup file to launch it and install Crystal Ball and then run the Crystal Ball License Manager to license Crystal Ball using the license serial number provided for each user Instructions are the same as those given in the current Crystal Ball Installation and Licensing Guide Note Users of Crystal Ball Runtime applications must meet the usual Crysta
333. trials and the mean of the forecast in B7 at that point are put into cells on sheet 4 Worksheets sheet1 Activate For i 1 To 10 CB Simulation 100 Worksheets sheet4 Range A1 Offset i Value CB Iterations Worksheets sheet4 Range B1 Offset 1 Value _ CB GetForeStat Range B7 2 Next 1 CB Iterations Example 2 In a worksheet cell you can enter CB IterationsFEN Example 2 enters the number of trials run so far into the cell CB Iterations Related Call Name Description CB Simulation Runs a simulation for a specified number of iterations 180 Crystal Ball Macro Calls CB LockFitParm This subroutine enables you to enter specific parameters for selected distributions when selecting distributions for fitting This can be helpful when locking to a specific value for location shape degrees of freedom or other parameters can improve accuracy Table 140 CB LockFitParm Parameters with Values Parameter Dist VBA Data Type Integer Value See Table 53 for constant equivalents to the distributions listed under Description Description Specifies the distribution with parameters to lock The following distributions from Table 53 can be used e Gamma distribution Location Shape parameters e Lognormal distribution Location parameter e Student s t distribution Degrees of Freedom parameter e Weibull distribution Location Shape parameters e B
334. ts 4 Launch the application which should then launch Excel and Crystal Ball From then on the application should be self documenting with clearly labeled controls text boxes messages and prompts to guide users through the application workflow Note These instructions assume that your application sets a reference to cbdevkit xla To do this start Excel and select Tools then Macros and then Visual Basic Editor Then select Tools then References and select cbdevkit xla you might have to browse for it in the folder where Crystal Ball is installed Once you save your application file you should not have to do these steps again In Excel 2007 display the Developer tab as described in step 1 above Then select Visual Basic then Tools and then References and check cbdevkit xla Crystal Ball Runtime Licensing Requirements Crystal Ball and related products must be used in accordance with the applicable Oracle license agreement Crystal Ball Runtime Licensing Requirements 267 268 Crystal Ball Runtime Using the OptQuest Developer Kit In This Appendix About the OptQuest DA A a 269 OptQuest Developer Kit Use and SUCIA 270 Developme Opimizaton DOR 251 102520 19044362 pede tati p eod Ver d Las a Eod cer ded Cb itd aed bee RE bee bead d Rd 274 Userdetined Event Macros tor OpOIR ZGLIOITS 2 cta a ees twice lene ee 279 About the OptQuest Developer Kit Welcome to the OptQuest Developer Kit for Crystal Ball Decision Op
335. ts a predefined Integer See Table 39 n a report type or uses the settings defined by the various CB CreateRptND constants cbRptSheetName 33 Specifies the sheet name String The sheet name n a to create cbRptincludeCellLocs 34 Includes the cell location boolean True includes n a in the report the cell location information False does not cbRptSection 35 Indicates whether to boolean True includes Integer See Table 40 include or exclude entire the report section report sections specified in Value2 False excludes the specified section cbRptSectionOrder 36 Specifies the order of the String A string of ten n a report sections Note Sections must be explicitly included using comma separated values listed in Table 40 that specify the section order For CB CreateRptND 83 Named Constant Value Index Value Description Value1 Optional Value2 Optional cbRptSection example statements 1 6 7 8 2 3 4 5 9 10 indicates that the report should include sections in this order Summary Forecasts Assumptions Decision Variables Overlay Trend Sensitivity Scatter OptQuest results Predictor forecasts cbRptCapMetrics 37 Specifies whether to True includes the n a report capability metrics metrics False does not for forecasts in custom include the metrics reports cbRptScatterChart 38 Includes all open scatter boolean True includes Integer 1 to 200 chart
336. ts in selected cells using a dialog CB GetFore Retrieves information for a specific forecast cell CB SetFore Changes forecast attributes without redefining the forecast 114 Crystal Ball Macro Calls CB DeleteChart This call deletes a chart of the specified type and chart ID The chart ID is optional Ifthe chart ID is not specified the currently selected chart is deleted If the specified chart is not found a chooser dialog appears No error is returned Table 57 CB DeleteChart Parameters and Constants Parameter VBA Data Type Value Description SimChartType Integer cbChtOverlay 1 Specifies the type of chart cbChtScatter 2 you are deleting overlay cbChtSensitiv 3 scatter sensitivity or cbChtTrend 4 trend For named constant and index values see the Value column ChartID Optional String Chart ID The chart ID returned by CB EnumChart Table 59 entered directly or using CB EnumChart CB DeleteChart Example This example deletes the overlay chart trend chart and sensitivity chart specified with CB EnumChart CB CheckData CB CB CB DeleteChart cbChtOverlay CB EnumChart cbChtOverlay DeleteChart cbChtTrend CB EnumChart cbChtTrend DeleteChart cbChtSensitiv CB EnumChart cbChtSensitiv CB DeleteChart Related Calls Name Description CB CreateChart Creates a new chart of the specified type with the optional name if specified CB EnumChart Ret
337. ude uquadu ai qudd 123 CB ExtractDataND Example 1 A EAN ETA sx 130 CE Extract Data ND Exumple 2 amp ia AA AS 130 CEPSA Related CS rd AAA AAA 130 A papi d doe abd d Kew E d oan e e dde poa na CU oin rd 131 CIRIO A E rr b don ale die rr id 134 CRATES pirer wq see rhn En AR AA ARA RARA RAR Sq 134 Chi Wea Cils secar ad 134 CB Ponos Pel asin bes xad eus ee iii es 135 DH Formal PRESA isc AD a dat 193 a de MA adudeew UR ROCA UR COR CROP 135 CB FormatPrefsND e erai Pasa er sd be 3d xs 135 CB Tora PESE ND Example anu souaq eai ope oes RERO de pei 137 CB FormatPres ND Example 2 ir A kkr jaa 137 CE FormatPreRND Related Calls cora parara pri aa 138 CB Freeze 22 T ri AAA bee xs 138 GB Deere Exaile 4 iat SAA ERE ER HU aat Rad Esa 138 CB Freeze Related Calls ir AR AREE AR teases 138 CB FreezeND S Edd n ee at oy eee ex des E S 3d ee 138 CE Tee NDES MW rr m 140 CAL ori E epe 140 A Edu eter ud 140 CB GetAssum Example 1 5 52 rn bed os bes 142 CB GetAssum Example2 eee Tee rere D CRT 142 CB GetAssum Related Call corr A pp Rd 142 CB GetAssumPercent 44 i34 C 143 Case assur erent Example l rms ds RR eens 143 CE GetAssum ree PAGES Looscoceseseseeusdeebresesxevdqeseesgqus 144 CBGet amp ssumPercent Related Calle ancianas praia 144 CRONO 53 4 4 99 Oe eC EG eS eos eee eR AAA 144
338. ully an empty string is returned Table 28 CB CreateChart Returned Data Type Returned Value Returned Data Type The path and name of the new chart of the specified type ChartlD in the format String Current Results Sensitivity Charts Charts xls Sensitivity Chart 1 Table 29 CB CreateChart Parameters and Constants Parameter VBA Data Type Value Description SimChartType Integer cbChtOverlay 1 Specifies the type of chart cbChtScatter 2 you are creating overlay cbChtSensitiv 3 scatter sensitivity or trend cbChtTrend 4 chart For named constant and index values see the Value column DisplayName String Chart ID User defined or default Optional chart name title entered directly CB CreateChart Example This example creates an overlay chart a trend chart and a sensitivity chart and names each with the names in quotes ChartID CB CreateChart cbChtOverlay Overlay Chart 1 ChartID CB CreateChart cbChtTrend Trend Chart 1 ChartID CB CreateChart cbChtSensitiv Sensitivity Chart 1 CB CreateChart Related Calls Name Description CB CheckData Checks decision variables for validity initializes variables CB EnumChart Returns the unique name of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB CreateChart 79 CB CreateRpt This subroutine creates a Crystal Ball report It opens the Cre
339. umber of trials to run for each bootstrap sample Table 97 CB GetBootstrapOption Value Parameter Optional Variant Related Value VBA Data Type Description For Index2 7 cbBtsPercentCustom A string containing an Excel range to holds Used with cbBtsPercent and Variant a set of returned custom percentile values cbBtsPercentCustom to return custom percentile values and place them within the specified range CB GetBootstrapOption Example 1 This example returns the percentile setting used in the Bootstrap tool definition For this example the returned type would be cbBtsPercentCustom CB GetBootstrapOption cbBtsPercent CB GetBootstrapOption Example 2 This example returns a set of custom percentile values for example those stored in the Excel range F17 H17 as shown in CB BootstrapND Example 1 The returned values are placed in the specified range in this case F20 H20 CB GetBootstrapOption cbBtsPercent cbBtsPercentCustom F20 H20 CB GetBootstrapOption Related Calls Name Description CB Bootstrap Launches the Bootstrap tool CB BootstrapND Runs the Bootstrap tool without displaying dialogs 150 Crystal Ball Macro Calls CB GetCBAutoLoad In Crystal Ball 7 3 x or 11 x you can use the following alternatives to determine whether Crystal Ball launches each time Excel starts called autoloading e Start the Crystal Ball Application Manager and check or uncheck Automa
340. urns the chart ID of the next chart of the specified type CB SelectChart Selects the chart with the specified chart ID CB EnumAssum This function enumerates assumption cells for all open workbooks This command is useful for determining what assumptions have been defined for the open workbooks You can then call CB GetAssum for each assumption to retrieve specific information for example distribution type and parameters CB DeleteChart 115 Table 58 CB EnumAssum Returned Data Type Returned Value Returned Data Type The absolute cell reference of the next assumption in the format workbook sheet A 1 Variant For best results call CB CheckData once atthe beginning ofan enumeration to resetthe sequence of assumptions You should also call CB CheckData each time you add or delete data If the return string is empty all assumptions have been enumerated You can use the results of this subroutine to create a Range object You can only call this function from a subroutine or another function You cannot call this function from a worksheet Note Before calling this function call CB CheckData CB EnumAssum Example This example initializes all internal variables then steps through all the assumptions creating range objects from the returned string and putting their absolute cell references in column B of a worksheet CB CheckData Dim S As String Dim R As Range Dim t As Integer S CB EnumAssum While S
341. urrent settings for the Batch Fit tool CB GetBootstrapOption on page 148 Returns current settings for the Bootstrap tool CB GetCBAutoLoad on page 151 Returns the current Crystal Ball autoload setting that indicates whether Crystal Ball is set to open whenever Excel opens CB GetCertainty on page 151 Calculates the certainty level or probability of achieving a forecast value at or below a specific threshold CB GetCorrelation on page 153 Returns the correlation between two assumption cells CB GetDataAnalysisOption on page 154 Returns current settings for the Data Analysis tool CB GetDecisionTableOption on page 156 Returns current settings for the Decision Table tool CB GetDecVar on page 158 Retrieves information for a specific decision variable cell CB GetExcel2007ForegroundMode on page 160 Returns the current Run Preferences foreground mode setting for Excel 2007 in Normal speed Alphabetic List of Crystal Ball Macro Calls 29 Name CB GetFitParm on page 160 Description Returns the value of the specified distribution parameter for the last CB Fit call CB GetFore on page 162 Retrieves information for a specific forecast cell CB GetForeData on page 165 Returns specified forecast data for a given trial CB GetForePercent on page 166 Returns the value corresponding to a percentile for a specific forecast
342. use it is now handled in CB RunPrefsND Note To support the changes from CB RestoreRun and CB RestoreRunND to CB RestoreResults and CB RestoreResultsND the related constant returned from CB MacroResult has been changed from cbErrRestoreRun to cbErrRestoreResult The returned value is unchanged 248 Changes from Previous Versions The following spreadsheet functions are not included in this version of the Crystal Ball Developer Kit CB ExtremeValue CB ExtremeValue2 CB GetCorrelationEN CB GetDecVarFN CB GetForeFN CB GetVersionFN Changes to Existing Calls This section lists macro calls that have changed since the 2000 5 5 5 version of the Crystal Ball Developer Kit and describes the changes In the following updates constant index numbers are indicated in square brackets For example cbCelDistMedian 5 means constant cbCelDistMedian with index number 5 When constants are labeled deprecated they are currently accepted for compatibility but arecome obsolete in a future version and should not be used in new code CB ND e Documentation errors corrected the first parameter is renamed Prefltem and the index number for constant cbAssumShowMean is changed from 2 to 3 to match the code e The constant cbAssumShowCoordinates is removed obsolete in Crystal Ball 7 x and later including 11 x CB AutoDownshift e Starting with Crystal Ball version 7 2 this call changes from a subroutine to a function and returns the boole
343. use its methods and properties to access optimization variables that is to add modify and delete variables and options for running optimizations OptSetup Constraint This class represents an OptQuest constraint and accesses constraint properties OptSetup Decision This class serves as a wrapper for Crystal Ball decision variables and accesses their properties OptSetup Objective This class is responsible for handling all operations related to OptQuest objectives OptSetup OptEfficientFrontier This class accesses OptQuest settings for Efficient Frontier analysis OptSetup OptOptions This class accesses OptQuest option settings the preferences that control how long the optimization runs whether it stops automatically whether it runs deterministically or stochastically and more OptSetup Requirement This class is responsible for handling all operations related to OptQuest requirements Optimization Runtime Classes The following are the main OptQuest Developer Kit classes used to run optimizations and obtain results e OptRuntime main class for running an optimization and obtaining results e OptRuntime OptCounters e OptRuntime OptSolution 272 Using the OptQuest Developer Kit e OptRuntime OptVarStatistics e OptRuntime OptVarSolutionFilter e OptRuntime ResultsWindow e OptRuntime RuntimeEfficientFrontier e OptRuntime TestPointInfo OptRuntime OptRuntime is the main class for running optimizations and
344. utine to change the chart preferences for a single forecast or assumption If you call this subroutine to change a single forecast or assumption chart A11 is False when no forecast or assumption cell is selected CB MacroResultDetail NewValue returns error code 5102 Table 22 CB ChartPrefsND Parameters Parameter VBA Data Type Description Index Integer Sets basic forecast and assumption chart preferences according to the Value parameter settings For constant and index values see Table 23 Value Variant Works with the Index parameter to set forecast and assumption chart preferences For available value settings see Table 24 Crystal Ball Macro Calls Parameter VBA Data Type Description A11 Optional Variant True applies settings to all assumptions or forecasts False applies settings only to the selected assumption or forecast The default is False Note Optional parameters SeriesAxisIndex Value2 and Value3 are currently not supported The Index parameter Table 23 works with the Value parameter Table 24 to set basic forecast and assumption chart preferences Table 23 CB ChartPrefsND Index Parameter Values Required Integer Named Constant Value Index Value Description cbChtChartType 1 Sets the chart type according to the Value setting cbChtDistType 2 Sets the distribution type according to the Value setting cbChtGroups 3 Sets the grouping in the histogram acc
345. utoOpenCharts 0 data in columns DataOrientation DataAnalysisFitTol Distribution True i square ranking method lysisRankingMethod B1 D100 True True cbFitChiSquare CB DataAnalysisND 95 Run tool CB DataAnalysisND cbDataAnalysisRun CB DataAnalysisND Related Calls Name Description CB DataAnalysis Launches the Data Analysis tool CB GetDataAnalysisOption Returns current settings for the Data Analysis tool CB DecisionTable This call launches the Decision Table tool wizard This tool runs multiple simulations to test different values for one or two decision variables The tool tests values across the range of the decision variables and puts the results in a table that you can analyze using Crystal Ball forecast trend or overlay charts Note Before calling CB DecisionTable reset the simulation CB DecisionTable Example This example resets Crystal Ball and opens the Decision Table wizard CB Reset CB DecisionTable CB DecisionTable Related Calls Name Description CB DecisionTableND Runs the Decision Table tool without displaying dialogs CB GetDecisionTableOption Returns current settings for the Decision Table tool CB DecisionTableND The Decision Table tool runs multiple simulations to test different values for one or two decision variables This call runs the Decision Table tool and displays results without using a dialog Note Before calling CB De
346. utoload setting that indicates whether Crystal Ball is set to open whenever Excel opens CB SetCBAutoLoad Sets or cancels autoloading with Excel determines whether Crystal Ball is set to open whenever Excel opens CB Shutdown Closes Crystal Ball while leaving Excel open CB StopMultiSimul This subroutine more effectively uses resources when running multiple simulations with CB Simulation Call CB StartMultiSimul before multiple simulations and then call CB StopMultiSimul after the simulations are run See the example for CB StartMultiSimul CB StopMultiSimul Related Calls Name Description CB Simulation Runs a simulation CB StartMultiSimul Marks the start of multiple simulations CB TrendPrefs Opens the Trend Preferences dialog for the selected trend chart either open or closed If more than one trend chart is found opens a chooser dialog If no trend chart has been defined this call creates a new chart with no associated forecast using the default preferences This chart then becomes the selected chart for subsequent trend chart calls A simulation must be run before this call is used CB TrendPrefs Example This example runs a simulation either creates a trend chart selects a single trend chart or opens a chooser dialog if there are multiple trend charts and then opens the Trend Preferences dialog for the selected trend chart CB Simulation 1000 CB TrendPrefs CB TrendPrefs Related Calls
347. variable in a cell with a formula a cell reference or text If a simulation runs before this subroutine is used the simulation must be reset before the decision variable is defined Note Before calling this subroutine reset the simulation and select a cell CB DefineDecVar Example This example selects cell B5 a single value cell and then opens the Define Decision Variable dialog so you can define or redefine a decision variable CB ResetND Range B5 Select CB DefineDecVar 108 Crystal Ball Macro Calls CB DefineDecVar Related Calls Name CB DefineDecVarND Description Defines or changes the decision variable in a selected cell without using a dialog CB GetDecVar Retrieves information for a specific decision variable cell CB SetDecVar Changes certain attributes for a decision variable CB DefineDecVarND This subroutine defines or changes a decision variable in the selected cell without using a dialog If a simulation runs before this subroutine is used the simulation must be reset before the decision variable is defined Note Before calling this subroutine select a cell Table 54 CB DefineDecVarND Parameters Parameter Min VBA Data Type Variant Value Any positive or negative number Description Specifies the minimum lower bound of the decision variable Must be an integer for the Category decision variable type ignored for decision variable types Binar
348. variables from a chart CB ScatterPrefsND cbScatterManageFore cbScatterRemoveAllVars The next command adds forecast from D7 to the scatter chart as a target Range D7 Select CB ScatterPrefsND cbScatterManageFore CB ScatterPrefsND cbScatterSetTarget True The next commands add assumptions D4 through Range D4 Select CB ScatterPrefsND cbScat Range D5 Select CB ScatterPrefsND cbScat D6 Select CB ScatterPrefsND cbScat Range The next command sets CB ScatterPrefsND cbScat The next command makes CB ScatterPrefsND cbScat terViewType terManageAssum terManageAssum terManageAssum the scatter chart title terTitle Piston cbScatterAddSelectedVar D6 to the scatter chart cbScatterAddSelectedVar cbScatterAddSelectedVar cbScatterAddSelectedVar Displacement Scatter View sure the scatter chart is in Scatter view cbScatterView 206 Crystal Ball Macro Calls a 1 The next command sets minimal plot size valid range is 1 10 CB ScatterPrefsND cbScatterPlotSize 1 The next command sets Criteria Limit to Auto displays number of plots appropriate to plot size CB ScatterPrefsND cbScatterCriteriaLimit cbScatterLimitAuto 1 The next commands specify properties of the plot points triangle size 4 color light green CB ScatterPrefsND cbScatterDrawPoints True CB ScatterPrefsND cbScatterPointSymbol cbScatterPointSymbolTriangle C
349. vdc i dine 480436 xi uA E Raw di 78 CB Create hart caida nada ada lr S ETN gt 79 CB CreateChart Example AAA or EE e do 79 CBE Chant Related CUR 4 ae dDpER ae ae een PEOR UR Eon eg de jw Xe i Pr 80 CB CreateRpt Example A qQECEddbe RES RE S pei dide 80 CB CreateRpt Related Calls err eus ee ee Pus ore des eee 80 Oe Tai 2 os ee eee re ee ee A a CB CreateRptND Example 1 M TOT 89 CB CreateRptND Example2 res sea 90 CELER Rdated Calle vos goad see san qi aera auk vetera D e minuti l AS 91 CB DataAnalysis Example SETE I E EEE d Reseed ANET 91 CB DataAnalysis Related Calls ws bes aya ee bus sori sss 91 CE Dorana END visi x E dA ERE DEUS E RS x EX DNE NEG bs LES x Page Rd 91 CB DataAnalysii ND Example 52 2222 ueadqkuukbXkechbuxaRbd a bae dae us 95 CB DataAnalysisND Related Calls ver ee pde sss 96 CE Deci DONDE pen a oie or do ER He Oks de QUE e eR de ri leo NR Cl ree i arar a The bux aoe Ed dips 96 CB Decision Table Related tos uude quesaecbessbfuacRkeQeRa RR iaa 96 CB DecisionTableND Pd ius or news ss 96 CR Decision PASE D ERIS AMA 98 CB DecisionTableND Related Calls cx add Ded a dd eds 99 CB DefineAltParms er apes ad Re ideas 99 DID GUIDE Esap uu deu qe ode pd Rer e Oe oe pore MR CE Dek
350. vkit chm is a reference help file with lists and descriptions of methods and properties in Predictor Developer Kit classes It also contains information on the OptQuest Developer Kit available with Oracle Crystal Ball Decision Optimizer Fusion Edition For more information about CB Com Devkit chm see CB Com Devkit chm on page 274 Although the information there refers to the OptQuest Developer Kit the information is basically the same for the Predictor Developer Kit Be aware that class names are different as described in Important Predictor Classes on page 287 Toledo Gas xls is a Crystal Ball example file used as a tutorial example in the Oracle Crystal Ball Predictor User s Guide It contains annotated code that performs similar tasks to those described in the Predictor User s Guide To view the Predictor Developer Kit sample code 1 Open Toledo Gas xls From the Window task bar you can select Start then All Programs then Oracle Crystal Ball then Examples and then View Examples Guide From the list of examples select Toledo Gas With the example model open open the Microsoft Excel Visual Basic Editor In the Editor select Tools and then References Confirm that CBCOMDewvKit is selected in the list In the Project Explorer select Module1 for Toledo Gas xls ao fF WwW N Study the code annotations for examples of how to perform basic Predictor operations As you study the code annotations refer to basic code st
351. w lists and descriptions of methods the classes themselves and other important development information Figure 2 CB Com Devkit chm Opened to the Constraint Properties Topic for OptQuest E CB Com Devkit s lt 5 Hide Locate Back Forward Stop Refresh Home Contents index Search Collapse All Language Filter C See Also CB Com Devkit Constraint Properties QQ Decisioneering CB CBCOMDevKt Optimization Namespace A E BooleanOption Enumeration b El e ConEnumerator Class B 6 Constraint Class The Constraint type exposes the following properties VERA Constraint Type Property Properties B Equation Property E o DecEnumerator Class J XNA Framework E e Decision Class 4 Public J Instance 4 Declared Only a ero Protected d Static A Inherited sie T Compad E Objective Class E Q amp ObjEnumerator Class El e ObjReqBase Class B OptCondition Type Enumeration B OptConstraint Type Enumeration El e OptCounters Class El OptDecision Type Enumeration E OptEFFBoundType Enumeration El e Opt Efficient Frontier Class E OptEFFSelectionType Enumeration E OptEFFTest Type Enumeration El e OptimizationEvents Interface Member Description Comment Var comment Inherited from OptVar ConstraintType Is constraint linear DisplayName Var display name Inherited from OotVar EFDisplayName Var Efficient Frontier display name empty string if var is not defined as Efficient Frontier Inherited fro
352. y and Custom Max Variant Any positive or negative number equal to or greater than Min Specifies the maximum upper bound of the decision variable Must be an integer for the Category decision variable type ignored for decision variable types Binary and Custom StepSize Optional Variant Number less than Max Min Specifies a positive step size for discrete decision variables If decVarType is not used indicates whether the decision variable type is Continuous StepSize is 0 or blank or Discrete StepSize is greater than 0 ignored for decision variable types Binary Category and Custom NameOf Optional Variant Title surrounded by quotes Specifies how Crystal Ball identifies the decision variable Names the decision variable If you do not specify a name Crystal Ball uses the first of CB DefineDecVarND 109 Parameter VBA Data Type Value Description either the cell s range name text from the cell to the left text from the cell above or the cell s coordinates decVarType Optional Integer See Table 55 Sets the decision variable type to Continuous Discrete Binary Category or Custom described in Table 55 customData Optional String A list of at least two values separated by commas or a reference to a range of cells containing these values decimal values can be used The range must be one dimensional adjoining
353. yed the equivalent of the Show Forecasts As Defined dialog setting For Index 5 cbTwoDShowTargetFore 2 Returned to indicate that only cbTwoDForeOption Integer the target forecast is displayed the equivalent of the Show Only Target Forecast dialog setting For Index 5 cbTwoDHideFore 3 Returned to indicate that all cbTwoDForeOption Integer forecasts are hidden the equivalent of the Hide All Forecasts dialog setting For Index 6 cbTwoDShowForeStat 1 Returns a boolean value2 cbTwoDOutputOption Integer parameter to indicate whether to include forecast statistics in the output report if followed by True includes statistics in the report For Index 6 cbTwoDShowPercentiles 2 Returns a boolean value2 cbTwoDOutputOption Integer parameter to specify whether to include percentiles in the output report if followed by True includes percentiles in the report 174 Crystal Ball Macro Calls Related Value Value or Named Constant Index Description For Index 6 cbTwoDShowCapMetrics 3 Returns a boolean Value2 cbTwoDOutputOption Integer parameter to specify whether to include capability metrics in the output report if followed by True includes capability metrics in the report For Index 7 cbTwoDPercentTenNinety 1 Returned by cbTwoDPercent to cbTwoDPercent Integer indicate the 10th and 90th percentiles For Index 7 cbTwoDPercentFiveNinetyFive 2 Returned by cbTwoDPercent to cbTw

Download Pdf Manuals

image

Related Search

Related Contents

8106 User Manual No Abe.cdr  Safety and Operation Manual Manuel de l`opérateur et de sécurité  —I : MODE D`EMPLOI RAPIDE  LEICA SPRINTER – Nível Electrónico  AAA Membership Benefits Guide AAA Membership  study of sms security as part of an electronic voting system  大会鑑 - 秋田陸上競技協会  Manual de uso y mantenimiento  

Copyright © All rights reserved.
Failed to retrieve file