Selecting different columns depending on condition

Hi there,
I have a requirement where I run a query and depending on one of the conditions I need a different set of columns returned, and each of the columns is in a different row. i.e.
table1
id key val
2  2_1 val2_1
2  2_2 val2_2
5  5_1 val5_1
5  5_2 val5_2
5  5_3 val5_3
5  5_4 val5_4Then I'd like something like this:
select val from table1
where if id = 2 then return val where key in ('2_1', '2_2') else
if id = 5 then return val where key in ('5_1', '5_2', '5_4') else
if id = ....The output for instance I'd expect if id=5 is:
val5_1, val5_2, val5_4I need to be able to manually put which values to return for each id. I don't necessarely need all values of an id.. for instance I left out val5_3 where id = 5.
Is this possible? I have like 20 ids, and it's either doing something like this or create 20 specific queries. Please let me know if more clarification is needed.
Thanks,

malky wrote:
Thanks Alberto, I've used pivot before as functions of "max(decode(rn,1,nm)) ", I didn't notice your PIVOT in there, but I cannot use it, i should have mentioned i'm using 10g.
That is why the FAQ SQL and PL/SQL FAQ are saying to always post your Oracle version as result of this query:
SELECT * FROM v$version;If you are not using 10g then you have to go to a pivoting pre-11g solution that are also mentioned in the FAQ.
The substr(key,3) in my case the Id not always has the same keys, so what if i remove your substr function? would it still work?
Also, you're specifying 4 columns, there might be more, does that mean i'll have to hardcode the max number of columns an id would have and use them in all of them? or can that be replaced by what I posted earlier on?
CASE WHEN id = 2 and key='2_1' THEN val END
That is exactly what you can do.
my only problem with this is that i cannot specify the "," demiting the next columnSorry, I did not get this point. Could you explain it better?
In your case you can do in this way. You will have to hardcode the value in any case:
WITH mydata AS
   SELECT 2 id, '2_1' key, 'val2_1' val FROM DUAL UNION ALL
   SELECT 2 id, '2_2' key, 'val2_2' val FROM DUAL UNION ALL
   SELECT 5 id, '5_1' key, 'val5_1' val FROM DUAL UNION ALL
   SELECT 5 id, '5_2' key, 'val5_2' val FROM DUAL UNION ALL
   SELECT 5 id, '5_3' key, 'val5_3' val FROM DUAL UNION ALL
   SELECT 5 id, '5_4' key, 'val5_4' val FROM DUAL
SELECT MAX(CASE
              WHEN id = 2 and key = '2_1'
                OR id = 5 and key = '5_1'
              THEN
                 val
           END) AS val1
     , MAX(CASE
              WHEN id = 2 and key = '2_2'
                OR id = 5 and key = '5_2'
              THEN
                 val
           END) AS val2
     , MAX(CASE
              WHEN id = 5 and key = '5_3'
              THEN
                 val
           END) AS val3
     , MAX(CASE
              WHEN id = 5 and key = '5_4'
              THEN
                 val
           END) AS val4
  FROM mydata
GROUP BY id;
VAL1   VAL2   VAL3   VAL4 
val2_1 val2_2             
val5_1 val5_2 val5_3 val5_4If you think it can be done in a different way, please post some sample data reflecting as much as possible your real data.
Regards.
Al

Similar Messages

  • Cannot Select IR Columns when IR condition is request = e1

    Hello: I'm on 4.1.1 and have long-running interactive report. I created a filter criteria region above the IR that contains a button to show the report (since it is long running). The button is a branch back to same page with a request (I also had trouble with dynamic action on button that submitted the page with request, but just kept moving along :-) ). The IR report display condition is based on the request. I have it working fine, but now I cannot add columns to the report by clicking on Actions > Select Columns. It just spins/hangs.
    Is this a bug?
    I recreated the issue here... http://apex.oracle.com/pls/apex/f?p=25081:2 This is first time I have recreated issue for this forum on apex.oracle.com so not sure of authentication protocol when sharing apps for questions to this forum (I used no auth) - so advice on that is welcome too.
    Thanks, Hawk

    Hello Jari: Further testing revealed that I now cannot export an excel spreadsheet with your design. I click Action > Download > CSV and then the report goes blank. I assume there is another submit in there when I try to download. If this additional submit has a request then I suppose I can make it work if I know the value of the request.
    I have removed the computation copied from your design (which beside the above issue worked great) and replaced it with an application process (AP). The AP will set the show_report item to 'N' whenever the only link to that page is clicked - which is a tab. I learned how to get tab's request value from ATD's post: Re: set item value depends on tab request (I will also revisit that thread since it gets into cookies stuff which I want to understand better)
    This new design appears to work fine.
    Thanks, Hawk

  • Different conditions for different columns

    Hi,
    I have two tables and both have 3 common columns. I have to write a query joining the two tables and get different columns with different conditions.
    For e.g., I have the tables test and test1.
    create table test (a1 varchar(10), a2 varchar(10), a3 varchar(10), a4 date, a5 number, a6 number, a7 number, a8 number);
    create table test1 (a1 varchar(10), a2 varchar(10), a3 varchar(10));
    insert into test1 values('abc', 'a', 'z');
    insert into test1 values('xyz', 'b', 'y');
    insert into test values('abc', 'a', 'x', trunc(sysdate,'MM'), 100, 200, 300, 400);
    insert into test values('abc', 'b', 'z', trunc(sysdate,'MM'), 567, 4778, 4234, 6767);
    insert into test values('xyz', 'a', 'y', trunc(sysdate,'MM'), 5467, 2134, 5678, 8332);
    insert into test values('xyz', 'b', 'z', trunc(sysdate,'MM'), 3534, 744, 678547, 46);
    insert into test values('abc', 'a', 'x', trunc(add_months(sysdate,-1),'MM'), 700, 800, 900, 600);
    insert into test values('abc', 'b', 'z', trunc(add_months(sysdate,-1),'MM'), 565477, 474578, 4456234, 226767);
    insert into test values('xyz', 'a', 'y', trunc(add_months(sysdate,-1),'MM'), 235467, 2342134, 255678, 258332);
    insert into test values('xyz', 'b', 'z', trunc(add_months(sysdate,-1),'MM'), 324534, 25744, 678547, 78846);
    select * from test1;
    A1     A2     A3
    abc     a     z
    xyz     b     y
    select * from test;
    A1     A2     A3     A4                     A5     A6     A7     A8
    abc     a     x     05/01/2010 00:00:00     100     200     300     400
    abc     b     z     05/01/2010 00:00:00     567     4,778     4,234     6,767
    xyz     a     y     05/01/2010 00:00:00     5,467     2,134     5,678     8,332
    xyz     b     z     05/01/2010 00:00:00     3,534     744     678,547     46
    abc     a     x     04/01/2010 00:00:00     700     800     900     600
    abc     b     z     04/01/2010 00:00:00     565,477     474,578     4,456,234     226,767
    xyz     a     y     04/01/2010 00:00:00     235,467     2,342,134     255,678     258,332
    xyz     b     z     04/01/2010 00:00:00     324,534     25,744     678,547     78,846I have to write a query to get values for columns a1, a4, a5, a6, a7 and a8. For each distinct month fro mthe column a4, the values for columns a1, a4 a5 and a6 should be based on the condition test1.a1=test.a1 and test1.a2=test.a2. The condition for columns a7 and a8 should be test1.a1=test.a1 and test1.a3=test.a3.
    How can I do this?
    Thanks,
    Machaan

    remove the 4th join and only duplicate test;
    SQL> ed
    Wrote file afiedt.buf
      1  select distinct
      2  case
      3          when t11a1 is null then
      4            t12a1
      5          else
      6            t11a1
      7        end as a1
      8        ,case
      9          when t11a4 is null then
    10            t12a4
    11          else
    12            t11a4
    13         end as a4
    14        ,case
    15          when t11a5 is null then
    16            t12a5
    17          else
    18            t11a5
    19         end as a5
    20  from (
    21        select t11.a1 as t11a1
    22              ,t11.a2 as t11a2
    23              ,t11.a3 as t11a3
    24              ,t11.a4 as t11a4
    25              ,t11.a5 as t11a5
    26              ,t11.a6 as t11a6
    27              ,t11.a7 as t11a7
    28              ,t11.a8 as t11a8
    29              ,t12.a1 as t12a1
    30              ,t12.a2 as t12a2
    31              ,t12.a3 as t12a3
    32              ,t12.a4 as t12a4
    33              ,t12.a5 as t12a5
    34              ,t12.a6 as t12a6
    35              ,t12.a7 as t12a7
    36              ,t12.a8 as t12a8
    37        from test1 t1
    38            ,test  t11
    39            ,test  t12
    40        where t1.a1 = t11.a1
    41        and   t1.a2 = t11.a2
    42        and   t1.a3 = t12.a3
    43* )
    SQL>
    SQL> /
    A1         A4                A5
    xyz        01-APR-10     324534
    xyz        01-MAY-10       3534
    abc        01-APR-10        700
    abc        01-MAY-10        100

  • Use different column Name in Analytic View depending by logon session language

    Hi everybody.
    Is it possible to have different column names for ONE single Analytic View column depending by the Client session language?
    For instance:
    - we have one (only one)  column name let's say that is 'fatturato' (for an Italian Client session) and 'invoiced' (for an English Client session) etc.. etc..
    in other word the 'column name' changes depending by the language but the column is only 1 (one).
    Is it possible to manage this and how? In SAP Hana Studio?
    Is it possible to store in some way the different names of that column and relate them to the column itself?
    Thank you in advance
    Best regards.
    Sergio

    Hi Sumeet.
    We already did your suggestion...
    But after the action:
    " tab--> Migrate--> Add---> OK"
    what do you have to do to have a multi-language column naming?
    Let's say we have a column name = 'product' (in English).
    We'd like to have for the same column also the following name:
    - 'prodotto'  ->  for Italian
    - 'produit'  -> for French
    - 'produkt' -> for German
    .. and so on
    depending  by the Client session language (and this has to be done automatically of course).
    How this can be achieved?
    Thank you
    Sergio

  • Summing Selected Rows in Column Depending on Value in Another Column

    I'd like to sum only the values in selected rows in a given column depending on the value of another column in the same row. For example, suppose I have a table (please disregard the underscores, needed for correct alignment):
    ___A____B____C___D
    1__5___10___15___0
    2_20___25___30___1
    3_35___40___45___1
    4_50___55___60___0
    5__sum(D=1)
    In cell B5, I'd like to compute the sum of only rows in column B for which the value of the corresponding column D is 1. In this case B5 would be 65.
    How can I do this using functions? Is it possible to do it for a variable range of rows without specifying each row individually?
    Thanks,
    Dave

    You should place your formula to other collumn then calculated ones or in another table. You will be able to calculate whole collumns with: =SUMIF(D;“=1”;B)
    Formula for your example is: =SUMIF(D1:D4;“=1”;B1:B4)
    VB

  • How to select few columns based on certain conditions

    i have a table with n columns, of which in 2 columns each may have similar values for certain number of rows
    i want to find if one of the entries in a column has same value in the next few rows
    For example the two columns are
    supplier_name supplier_code
    hll 013
    hll 013
    hll 013
    hll 013
    if i first encounter hll with 013 i have to check whether hll with 013 record is further available
    if it is so i have to display the columns for which multiple entries is available
    can anyone send the query

    Duplicate thread?
    selecting certain columns in oracle

  • Show report in different currency depending on user parameter

    hi all,
    i'm trying to show my report in different currency, depending on users given parameter.
    i hold my account balance in USD based. User should select one parameter, in which currency they want to see their account balance. (e.g. EURO, GBP ...) and depending on their selection, i want to convert USD based info into chosen currency, by fetching field from currency table and making some calculation.
    also i want to include in report currency($, £ ...) accordingly ().
    how can i achieve this, has somebody any suggestion to me?
    thanks in advance.
    bogi.

    hi,
    i think i need to explain my problem more detailed. anyone who has suggestion, please help me.
    i have 3 tables account, times and currency.
    - times table has time_key, date, day_of_week fields.
    - account table has - account_balance and time_key_FK fields.
    - currency table has currency_type, amount, time_key_FK fields.
    1. i have function decode(:Currency,'USD',account_balance,'EURO',--here i want to replace my calculation CALC1---)
    CALC1- this calculation need to some calculation like this: account_balance * (fetched field from this sql)(select amount from currency, account where currency.currency_type='EURO' and account.time_key_FK=currency.time_key_FK)
    i tried to do this, but discoverer plus doesn't let me make condition and calc. i'm very confused.
    2. after i achieve this query, somehow i want to display on worksheet on which currency is it based. can i get parameter value, and show this value as in column heading?
    tnx!!!

  • Getting DISTINCT count from two different columns

    Hi all,
    I have following query which gives currency code from two different tables. I would like to get the distinct count of currency codes from these two different columns.
    SELECT eb.person_seq_id, eb.bonus_amount, eb.currency_cd, ed.currency_cd_host
    FROM fr_emp_bonuses eb, fr_emp_details ed, fr_periods p
    WHERE eb.person_seq_id = ed.person_seq_id AND ed.period_seq_id = eb.period_seq_id
    AND ed.period_seq_id = p.period_seq_id AND p.period_status = 'CURRENT'
    AND eb.bonus_amount >= 0 AND eb.person_seq_id = 3525125;
    This query gives following result
    3525125     240000     USD     INR
    3525125     0      USD     INR
    3525125     60000      USD     INR
    3525125     50000      USD     INR
    There are two distinct currency codes (USD, INR) and total amount is 350000. So I am looking for a query to give me the following result
    3525125     350000 2
    Thanks in advance

    Hi,
    Here's one way:
    WITH     original_query     AS
         SELECT  eb.person_seq_id
         ,     eb.bonus_amount
         ,     eb.currency_cd
         ,     ed.currency_cd_host
         FROM     fr_emp_bonuses         eb
         ,     fr_emp_details          ed
         ,     fr_periods          p
         WHERE      eb.person_seq_id    = ed.person_seq_id
         AND      ed.period_seq_id    = eb.period_seq_id
         AND      ed.period_seq_id    = p.period_seq_id
         AND      p.period_status         = 'CURRENT'
         AND      eb.bonus_amount     >= 0
         AND     eb.person_seq_id    = 3525125
    ,     unpivoted_data     AS
         SELECT     person_seq_id
         ,     bonus_amount
         ,     currency_cd
         FROM     original_query
        UNION ALL
            SELECT  person_seq_id
         ,     0               AS bonus_amount
         ,     currency_cd_host     AS currency_cd
         FROM     original_query
    SELECT       person_seq_id
    ,       SUM (bonus_amount)          AS total_bonus_amount
    ,       COUNT (DISTINCT currency_cd)     AS distinct_currency_cds
    FROM       unpivoted_data
    GROUP BY  person_seq_id
    ;There may be a shorter, more efficient way to get the same results, but without knowing more about your tables, I can't tell.
    The tricky thing is getting two columns (currency_cd and currencuy_cd_host in this case) counted together. You can't simply say
    COUNT (DISTINCT eb.currency_cd) +
    COUNT (DISTINCT ed.currency_code_host)That happens to get the correct result with the sample data you posted, but what if you had data like thEe following?
    currency_cd     currency_cd_host
    INR          USD
    USD          INRHere, the count of distinct currency_cds is 2, and the count of distinct currency_cd_hsots is also 2. Does that mean the grand total is 2 + 2 = 4? No, the 2 codes in one column arte the same 2 codes as in the other column. We need to get both currency_cd and currency_cd_hsot into the same column, and then do COUNT (DISTINCT ...) on that combined column. A UNION, as shown above, will certainly do that, starting with your query as you posted it. The query you posted isn't necessarily the best frist step towards this result, however, so there may be a much better approach, depending on your tables.
    Edited by: Frank Kulash on Feb 1, 2012 6:21 PM
    Here's a slightly shorter, and probably more efficient way to get the same results:
    WITH     cntr     AS
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL     <= 2
    SELECT       eb.person_seq_id
    ,       SUM (eb.bonus_amount)          AS total-amount
    ,       COUNT ( DISTINCT CASE
                        WHEN  c.n = 1
                        THEN  eb.currency_cd
                        ELSE  ed.currency_cd_host
                      END
              )               AS distinct_currency_cds
    FROM       fr_emp_bonuses    eb
    ,       fr_emp_details    ed
    ,       fr_periods          p
    ,       cntr              c
    WHERE        eb.person_seq_id  = ed.person_seq_id
    AND        ed.period_seq_id  = eb.period_seq_id
    AND        ed.period_seq_id  = p.period_seq_id
    AND        p.period_status   = 'CURRENT'
    AND        eb.bonus_amount   >= 0
    AND       eb.person_seq_i   = 3525125
    --       NOTE: no join condition involving c; we really do want a cross-join
    GROUP BY  eb.person_seq_id
    ;

  • Shading certain columns depending on start day of week.

    Good Afternoon,
    I have reason to edit the calendar wizard to make it completely automated.  And before anyone says that this isn't used anymore, we've received 2 separate calendar files over the last made from our Finance departments, each making them with Word calendar
    wizard highlighting year end dates.  So believe me, the calendar wizard is still very much in use!
    Last September, I finally figured out how to automate the first day of the week, though.  I have 2 templates now, one for Monday as first day and one for Sunday being the first day of the week.
    The only thing missing is to automate the shading so that the columns for Saturday and Sunday are shaded with light grey, and since it's automation we're talking about, only those cells in the columns with a number in them.
    I know it's do-able, I'm just not a vb expert, only being able to handle editing simple macros.
    But I understand that since I had some help with the macros and they might have changed from the original to some degree, that I should post the code.  Is this correct?  I hope that it is.
    ' WORD 97 WIZARD
    ' Calendar Wizard Specific Code
    Option Explicit
    ' CONSTANT DECLARATIONS
    '=============================== LOCALIZATION BLOCK ===============================
    ' Localization Note: iWeekStartDay is the starting day of the week (Sun = 0, Mon = 1, ...Sat = 6)
    Public Const iWeekStartDay As Integer = 1
    ' Banter strings
    Public Const strWarnYearReq As String = "Both starting and ending years are required."
    Public Const strWarnMinExceeded As String = "The year can not be before 1900."
    Public Const strWarnMaxExceeded As String = "The year can not be after 4095."
    Public Const strWarnRangeExceeded As String = "The calendar is limited to 120 months (10 years)."
    Public Const strAppCaptionPart1 As String = "Calendar: "
    Public Const strAppCaptionPart1b As String = ""
    Public Const strAppCaptionPart2 As String = ", "
    Public Const strAppCaptionPart3 As String = " to "
    Public Const strAppCaptionPart4 As String = ", "
    ' Status messages
    Public Const strStatusIntro As String = "Creating Calendar..."
    Public Const strStatusPart1 As String = "Creating "
    Public Const strStatusPart2 As String = ", "
    Public Const strStatusPart3 As String = "..."
    ' Assistant
    Public Const strCallBackHeading As String = "Do more with the calendar?"
    'Margins for A4 size (if wizard changes pagesize to A4)
    Public Const sA4_SHORT_MARGIN As Single = 28.8
    Public Const sA4_LONG_MARGIN As Single = 57.6
    'Margins for Letter size (if wizard changes pagesize to Letter) in pts
    Public Const sLETTER_SHORT_MARGIN As Single = 36
    Public Const sLETTER_LONG_MARGIN As Single = 36
    '========== END LOCALIZATION BLOCK - DO NOT MAKE CHANGES BELOW THIS LINE ==========
    Public Const iYearMin As Integer = 1900
    Public Const iYearMax As Integer = 4095
    ' Bookmark Names - DO NOT LOCALIZE
    ' Note: No spaces allowed in bookmark names
    Public Const strBkMkMonth As String = "Month"
    Public Const strBkMkDays As String = "Days"
    Public Const strBkMkDayNames As String = "DayNames"
    Public Const strBkMkYear As String = "Year"
    ' Calendar Style Names and Constants
    Public Const wzBOXES As Integer = 0
    Public Const wzBANNER As Integer = 1
    Public Const wzJAZZY As Integer = 2
    ' Form Control
    Public Const wzPAGE_START As Integer = 0
    Public Const wzPAGE_STYLE As Integer = 1
    Public Const wzPAGE_DIRECTION As Integer = 2
    Public Const wzPAGE_MONTHS As Integer = 3
    Public Const wzPAGE_FINISH As Integer = 4
    'orientation
    Public Const iORTN_PORTRAIT As Integer = 0
    Public Const iORTN_LANDSCAPE As Integer = 1
    ' Assistant
    Public Const iMAX_PANEL As Integer = 4 ' Number of last panel in MultiPage (First=0)
    Public Const iCALL_BACK_COUNT As Integer = 3 ' Number of items in CallBackBalloon (First=1)
    'postwizard balloon document variable
    Public Const strPOST_WIZ_BLN As String = "Calendar post wizard balloon"
    ' VARIABLE DECLARATIONS
    ' General
    Public rgstrMonthName(11) As String
    Public rgstrDayName(6) As String
    Public rgiDaysInMonth(11) As String
    Public fDateError As Boolean
    Public fCheckValidity As Boolean 'if set then the dates are checked for validity
    'variables used in doc. creation
    Public str1_TO_28 As String
    Public rgsDaysHeight(2, 1, 1) As Single
    Public rgsMonthNamesHeight(2, 1, 1) As Single
    Public rgstrDaysStyle(2) As String
    Public rgstrMonthNamesStyle(2) As String
    Public strSTY_BANNER_HDG3 As String
    ' Assistant
    Public rgstrAssistantMsg(iMAX_PANEL + 1) As String
    Public rgstrCallBackMsg(iCALL_BACK_COUNT) As String
    Public rgstrCallBackTip(iCALL_BACK_COUNT) As String
    ' Page 1
    Public iCalendarStyle As Integer
    Public iSavedStyle As Integer
    ' Page 2
    ' Page 3
    ' Page 4
    Public Sub InitWizardName(fDummy As Boolean)
    strWizName = "Calendar Wizard"
    strWizLongName = strWizName
    strWizShortName = "Calendar"
    End Sub
    Public Sub InitWizardStrings(fDummy As Boolean)
    Dim i As Integer
    On Error GoTo FatalError
    '=============================== LOCALIZATION BLOCK ===============================
    ' Note: this list is indexed 0 - iMAX_PANEL
    rgstrAssistantMsg(0) = "The Calendar Wizard helps you create a monthly calendar that you can customize with pictures and events. If you want to track and be reminded of events, you should probably use Microsoft Outlook, Microsoft Schedule+, or Microsoft Exchange."
    rgstrAssistantMsg(1) = "Select the look you want for your calendar. The Jazzy style uses the Algerian font. If it is not installed on your system, copy alger.ttf from the Valupack folder on the Microsoft Office CD to your hard drive."
    rgstrAssistantMsg(2) = "If you leave room for a picture, Word will insert a placeholder picture that you can replace with any picture you want."
    rgstrAssistantMsg(3) = "Your calendar can start on any month, and you can make your calendar shorter than or longer than 12 months. Each month will appear on a different page."
    rgstrAssistantMsg(4) = "To change any settings, click Back."
    ' Note: change constant iCALL_BACK_COUNT if number of items in list changes
    rgstrCallBackMsg(0) = "Add, remove, or replace a picture"
    rgstrCallBackMsg(1) = "Enter information into the calendar"
    rgstrCallBackMsg(2) = "Get Help on Something Else..."
    rgstrCallBackTip(0) = "To remove a picture, click on it and then press Delete. To add a picture, click where you want to insert the picture, point to Picture on the Insert menu, and then click From File."
    rgstrCallBackTip(1) = "To enter information, click where you want to insert the text and start typing. To move between different dates in the calendar, press Tab to move forward or press Shift+Tab to move to the previous date."
    'Load Month Name array
    rgstrMonthName(0) = "January"
    rgstrMonthName(1) = "February"
    rgstrMonthName(2) = "March"
    rgstrMonthName(3) = "April"
    rgstrMonthName(4) = "May"
    rgstrMonthName(5) = "June"
    rgstrMonthName(6) = "July"
    rgstrMonthName(7) = "August"
    rgstrMonthName(8) = "September"
    rgstrMonthName(9) = "October"
    rgstrMonthName(10) = "November"
    rgstrMonthName(11) = "December"
    'Load Day Name array LOCALIZATION NOTE: DO NOT CHANGE THE ORDER IN WHICH THESE APPEAR!
    ' TO CHANGE THE WEEK START DAY, CHANGE THE CONSTANT iWeekStartDay
    rgstrDayName(0) = "Sun"
    rgstrDayName(1) = "Mon"
    rgstrDayName(2) = "Tue"
    rgstrDayName(3) = "Wed"
    rgstrDayName(4) = "Thu"
    rgstrDayName(5) = "Fri"
    rgstrDayName(6) = "Sat"
    'Load Days In Month array
    rgiDaysInMonth(0) = 31
    rgiDaysInMonth(1) = 28 'Will not be used - must be calculated for leap year accuracy
    rgiDaysInMonth(2) = 31
    rgiDaysInMonth(3) = 30
    rgiDaysInMonth(4) = 31
    rgiDaysInMonth(5) = 30
    rgiDaysInMonth(6) = 31
    rgiDaysInMonth(7) = 31
    rgiDaysInMonth(8) = 30
    rgiDaysInMonth(9) = 31
    rgiDaysInMonth(10) = 30
    rgiDaysInMonth(11) = 31
    rgstrDaysStyle(wzBOXES) = "Boxes"
    rgstrDaysStyle(wzBANNER) = "Banner"
    rgstrDaysStyle(wzJAZZY) = "Jazzy"
    rgstrMonthNamesStyle(wzBOXES) = "Boxes Heading2"
    rgstrMonthNamesStyle(wzBANNER) = "Banner Heading2"
    'we dont set the style for month names in Jazzy style
    'the Banner style landscape calendar with picture uses Banner Heading3 style for month names
    strSTY_BANNER_HDG3 = "Banner Heading3"
    rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 0) = 55
    rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 1) = 55
    rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 36
    rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 36
    rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 0) = 56
    rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 1) = 102
    rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 72
    rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 71
    rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 0) = 60
    rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 1) = 60
    rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 55
    rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 51
    rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 0) = 64
    rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 1) = 110
    rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 81
    rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 81
    rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 73
    rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 73
    rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 62
    rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 59
    rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 40.5
    rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 81.8
    rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 58.2
    rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 57.5
    str1_TO_28 = ""
    For i = 1 To 28
    str1_TO_28 = str1_TO_28 & CStr(i) & vbTab
    Next i
    'strip off last tab
    str1_TO_28 = Left$(str1_TO_28, Len(str1_TO_28) - 1)
    ' Location in registry DO NOT LOCALIZE
    strRegSettingsKey = strREG_SETTINGS_BASE_KEY & "Calendar Wizard"
    Exit Sub
    FatalError:
    ReportError Err
    End Sub ' InitWizardStrings
    Public Sub InitWizard(fDummy As Boolean)
    ' Global Vars
    fWizardCallBack = False
    fDateError = False
    iCurrentPanel = 0
    ' Initialize strings
    InitWizardStrings (True)
    ' Create a new instance of the form
    Set formWizard = New formWizDlg
    If formWizard Is Nothing Then GoTo FatalError
    formWizard.lblWizName1.Caption = " " & strWizLongName & " "
    Exit Sub
    FatalError:
    DisplayErrorMsg strERR_INIT_FORM
    ReportError Err
    End Sub
    ' fDummy prevents sub from appearing in Word Tools/Macro list
    Public Sub SaveDialogValues(fDummy As Boolean)
    On Error GoTo FatalError
    ' Display status
    Application.ScreenUpdating = False
    System.Cursor = wdCursorWait
    StatusBar = strSAVE_SETTINGS
    ' Assistant
    System.PrivateProfileString("", strREG_SETTINGS_BASE_KEY, strREG_ASSISTANT_TIME_STAMP) = Format$(Now, "General Date")
    StoreValPref strREG_ASSISTANT_HELP, iLocalState
    ' Page 1
    StoreValPref "iCalendarStyle", iCalendarStyle
    ' Page 2
    StoreValPref "optPortrait", formWizard.optPortrait.Value
    StoreValPref "optPictureYes", formWizard.optPictureYes.Value
    ' Page 3
    StatusBar = ""
    System.Cursor = wdCursorNormal
    fSettingsSaved = True
    Application.ScreenUpdating = True
    Exit Sub
    FatalError:
    ReportError Err
    End Sub
    Public Sub RestoreDialogValues(fDummy As Boolean)
    Dim i As Integer
    On Error GoTo FatalError
    ' Display status
    Application.ScreenUpdating = False
    StatusBar = strRST_SETTINGS
    System.Cursor = wdCursorWait
    ' Page 1
    iCalendarStyle = IRestorePref("iCalendarStyle", 0)
    Select Case iCalendarStyle
    Case wzBOXES
    formWizard.optBoxes.Value = True
    formWizard.shpShadowBoxes.Visible = True
    Case wzBANNER
    formWizard.optBanner.Value = True
    formWizard.shpShadowBanner.Visible = True
    Case wzJAZZY
    formWizard.optJazzy.Value = True
    formWizard.shpShadowJazzy.Visible = True
    Case Else
    iCalendarStyle = wzBOXES
    formWizard.optBoxes.Value = True
    formWizard.shpShadowBoxes.Visible = True
    End Select
    ' Page 2
    If FRestorePref("optPortrait", False) Then
    formWizard.optPortrait.Value = True
    formWizard.shpPortraitShadow.Visible = True
    formWizard.shpLandscapeShadow.Visible = False
    Else
    formWizard.optLandscape.Value = True
    formWizard.shpPortraitShadow.Visible = False
    formWizard.shpLandscapeShadow.Visible = True
    End If
    formWizard.optPictureYes.Value = FRestorePref("optPictureYes", False)
    ' Page 3
    formWizard.cboMonthStart.ListIndex = Month(Date) - 1
    formWizard.cboMonthEnd.ListIndex = Month(Date) - 1
    formWizard.txtYearStart = Year(Date)
    formWizard.txtYearEnd = Year(Date)
    fCheckValidity = False
    StatusBar = ""
    System.Cursor = wdCursorNormal
    fSettingsRestored = True
    Application.ScreenUpdating = True
    Exit Sub
    FatalError:
    ReportError Err
    Exit Sub
    End Sub ' RestoreDialogValues
    ' fDummy prevents sub from appearing in Word Tools/Macro list
    Public Sub CreateNewDoc(fDummy As Boolean)
    Dim iMonthCurr As Integer
    Dim iYearCurr As Integer
    Dim lYearMonthCurr As Long
    Dim lYearMonthEnd As Long
    Dim iDaysCnt As Integer
    Dim iDaysInMonth As Integer
    Dim iCnt As Integer
    Dim strAutoTextName As String
    Dim objTableDays As Table
    Dim iRow As Integer
    Dim iCol As Integer
    Dim ocboMonthStart As ComboBox
    Dim ocboMonthEnd As ComboBox
    Dim otxtYearStart As TextBox
    Dim otxtYearEnd As TextBox
    Dim strJazzyDayNames As String
    Dim objFps As PageSetup
    Dim objRng As Range
    Dim sShortMargin As Single
    Dim sLongMargin As Single
    Dim strCaptionTxt As String
    Dim iOrientation As Integer
    Dim iNoPicture As Integer
    Dim i As Integer
    Dim strDays As String
    On Error GoTo CreateNewDoc_Error
    System.Cursor = wdCursorWait
    Set ocboMonthStart = formWizard.cboMonthStart
    Set ocboMonthEnd = formWizard.cboMonthEnd
    Set otxtYearStart = formWizard.txtYearStart
    Set otxtYearEnd = formWizard.txtYearEnd
    With Application
    .ScreenUpdating = False
    .StatusBar = strStatusIntro
    End With
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Collapse wdCollapseEnd
    If (formWizard.optPortrait) Then
    iOrientation = iORTN_PORTRAIT
    Else
    iOrientation = iORTN_LANDSCAPE
    End If
    iNoPicture = Abs(formWizard.optPictureNo.Value)
    'the margins have to be changed if papersize was changed in Common
    If (fChangeToA4 Or fChangeToLetter) Then
    Set objFps = ActiveDocument.PageSetup
    If iOrientation = iORTN_LANDSCAPE Then
    objFps.Orientation = wdOrientLandscape 'setting paper size in common
    'resets orientation to Portrait
    If fChangeToA4 Then
    sShortMargin = sA4_SHORT_MARGIN
    sLongMargin = sA4_LONG_MARGIN
    Else
    sShortMargin = sLETTER_SHORT_MARGIN
    sLongMargin = sLETTER_LONG_MARGIN
    End If
    Else
    If fChangeToA4 Then
    sShortMargin = sA4_LONG_MARGIN
    sLongMargin = sA4_SHORT_MARGIN
    Else
    sShortMargin = sLETTER_LONG_MARGIN
    sLongMargin = sLETTER_SHORT_MARGIN
    End If
    End If
    With objFps
    .TopMargin = sShortMargin
    .BottomMargin = sShortMargin
    .LeftMargin = sLongMargin
    .RightMargin = sLongMargin
    End With
    End If
    strAutoTextName = StrBuildAutoTextName(True)
    objWizTemplate.AutoTextEntries(strAutoTextName).Insert objActiveRange, True
    If iCalendarStyle <> wzJAZZY Then
    Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDays).Range
    Else
    Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDayNames).Range
    End If
    strJazzyDayNames = ""
    For iCnt = iWeekStartDay To 6
    strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
    Next
    For iCnt = 0 To (iWeekStartDay - 1)
    strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
    Next
    'Strip trailing Tab
    strJazzyDayNames = Left$(strJazzyDayNames, Len(strJazzyDayNames) - 1)
    objActiveRange.Text = strJazzyDayNames
    If iCalendarStyle <> wzJAZZY Then
    If (iCalendarStyle = wzBANNER) And (iOrientation = iORTN_LANDSCAPE) And (iNoPicture = 0) Then
    objActiveRange.Style = strSTY_BANNER_HDG3
    Else
    objActiveRange.Style = rgstrMonthNamesStyle(iCalendarStyle)
    End If
    objActiveRange.Select
    Selection.ConvertToTable wdSeparateByTabs, 1, 7
    End If
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Copy
    iMonthCurr = CInt(ocboMonthStart.ListIndex) + 1
    iYearCurr = CInt(otxtYearStart.Text)
    lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
    lYearMonthEnd = (CLng(otxtYearEnd.Text) * 100) + (CLng(ocboMonthEnd.ListIndex) + 1)
    'Create each month of the calendar
    Do Until lYearMonthCurr > lYearMonthEnd
    Application.StatusBar = strStatusPart1 & rgstrMonthName(iMonthCurr - 1) & strStatusPart2 & CStr(iYearCurr) & strStatusPart3
    'Set month
    If iCalendarStyle = wzJAZZY Then
    ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = CStr(iMonthCurr)
    Else
    ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = rgstrMonthName(iMonthCurr - 1)
    End If
    'Set year
    ActiveDocument.Bookmarks(strBkMkYear).Range.Text = CStr(iYearCurr)
    'Determine number of days in month
    If iMonthCurr = 2 Then
    iDaysInMonth = DateSerial(iYearCurr, 3, 1) - DateSerial(iYearCurr, 2, 1)
    Else
    iDaysInMonth = rgiDaysInMonth(iMonthCurr - 1)
    End If
    'Set Column of First Day Of Month by using Weekday function. The 8th
    'is used (to start with) instead of the 1st to allow for offsetting (via
    'iWeekStartDay) for localization since the 8th will always fall on the
    'same day (of the week) as the 1st.
    iCol = WeekDay(DateSerial(iYearCurr, iMonthCurr, 8 - iWeekStartDay))
    ActiveDocument.Bookmarks(strBkMkDays).Select
    If iCalendarStyle <> wzJAZZY Then _
    Selection.MoveDown wdLine 'the bookmark is now in the first cell of the table
    strDays = ""
    For i = 1 To iCol - 1
    strDays = strDays & vbTab
    Next i
    strDays = strDays & str1_TO_28
    For i = 29 To iDaysInMonth
    strDays = strDays & vbTab & CStr(i)
    Next i
    'to get a 6 * 7 table always
    For i = iDaysInMonth + iCol - 1 To 41
    strDays = strDays & vbTab
    Next i
    Set objActiveRange = Selection.Range
    objActiveRange.Text = strDays
    objActiveRange.Style = rgstrDaysStyle(iCalendarStyle) & iOrientation & iNoPicture
    objActiveRange.Select
    Selection.ConvertToTable wdSeparateByTabs, 6, 7
    Selection.Cells.Height = rgsDaysHeight(iCalendarStyle, iOrientation, iNoPicture)
    Selection.Tables(1).Rows(1).Height = rgsMonthNamesHeight(iCalendarStyle, iOrientation, iNoPicture)
    '========================================================
    ' Mn.Sept.01.2014; 08h21
    ' TABLE GRIDLINES CODE: Automatically creates printable gridlines in the table.
    With Selection.Tables(1).Borders
    .InsideLineStyle = wdLineStyleSingle
    .InsideLineWidth = wdLineWidth100pt
    .InsideColorIndex = wdAuto
    .OutsideLineStyle = wdLineStyleSingle
    .OutsideLineWidth = wdLineWidth100pt
    End With
    '========================================================
    ActiveDocument.Bookmarks(strBkMkDays).Delete
    'Advance the current month
    If iMonthCurr = 12 Then
    iMonthCurr = 1
    iYearCurr = iYearCurr + 1
    Else
    iMonthCurr = iMonthCurr + 1
    End If
    lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
    If lYearMonthCurr <= lYearMonthEnd Then
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Collapse wdCollapseEnd
    'Insert Page Break
    objActiveRange.InsertBreak wdPageBreak
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Collapse wdCollapseEnd
    objActiveRange.Paste
    End If
    Loop
    Application.StatusBar = ""
    strCaptionTxt = ""
    'Set Application caption
    strCaptionTxt = " - " & strAppCaptionPart1 & strAppCaptionPart1b & ocboMonthStart.Text & strAppCaptionPart2 & otxtYearStart.Text & strAppCaptionPart3 & ocboMonthEnd.Text & strAppCaptionPart4 & otxtYearEnd.Text
    ActiveDocument.UndoClear
    With ActiveWindow
    .Caption = .Caption & strCaptionTxt
    With .View
    .TableGridlines = False
    .ShowDrawings = True
    End With
    End With
    'Position cursor at the top
    Selection.HomeKey wdStory
    CreateNewDoc_Exit:
    Exit Sub
    CreateNewDoc_Error:
    ReportError Err
    GoTo CreateNewDoc_Exit
    End Sub ' CreateNewDoc
    Public Sub InitCallBack(fDummy As Boolean)
    Dim i As Integer
    Dim objCallBackLabels As BalloonLabels
    On Error GoTo ErrorCallBack
    If Not (fBlnInitialized) Then
    Set objPostWizBln = Assistant.NewBalloon
    fBlnInitialized = True
    With objPostWizBln
    .Heading = strCallBackHeading
    .Mode = msoModeModeless
    .Button = msoButtonSetCancel
    .BalloonType = msoBalloonTypeButtons
    .Callback = "Calendar.fnCallBack"
    End With
    Set objCallBackLabels = objPostWizBln.Labels
    objCallBackLabels.Count = iCALL_BACK_COUNT
    For i = 1 To iCALL_BACK_COUNT
    objCallBackLabels.Item(i).Text = rgstrCallBackMsg(i - 1)
    Next i
    End If
    objPostWizBln.Show
    If (Assistant.BalloonError) Then GoTo ErrorCallBack
    fPostWizBlnOpen = True
    Set objDocBln = ActiveDocument
    Set clsBln.app = Application
    ActiveDocument.Variables.Add strPOST_WIZ_BLN, "1"
    Exit Sub
    ErrorCallBack:
    DisplayErrorMsg strERR_INIT_CALL_BACK
    fPostWizBlnOpen = False
    Set objDocBln = ActiveDocument
    Set clsBln.app = Application
    ActiveDocument.Variables.Add strPOST_WIZ_BLN, "0"
    End Sub
    Public Function fnCallBack(objBln As Balloon, iBtn As Integer, lPrivate As Long)
    On Error GoTo ErrorCallBack
    Select Case iBtn
    Case Is < 1 'Exit
    objBln.Close
    fPostWizBlnOpen = False
    ActiveDocument.Variables(strPOST_WIZ_BLN).Value = "0"
    RestoreAssistant (True)
    Case 1 'Remove existing picture
    DisplayTip rgstrCallBackTip(0)
    Case 2 'Enter information into calendar
    DisplayTip rgstrCallBackTip(1)
    Case 3 ' Get help
    Assistant.Help
    End Select
    Exit Function
    ErrorCallBack:
    DisplayErrorMsg Err.Description
    End Function
    Private Function StrBuildAutoTextName(fDummy As Boolean) As String
    Dim strATName As String
    On Error GoTo BuildAutoTextName_Error
    'Select base AutoText Name NOTE: DO NOT LOCALIZE
    Select Case iCalendarStyle
    Case wzBOXES
    strATName = "Boxes"
    Case wzBANNER
    strATName = "Banner"
    Case wzJAZZY
    strATName = "Jazzy"
    End Select
    strATName = strATName & CStr(Abs(formWizard.optLandscape.Value))
    strATName = strATName & CStr(Abs(formWizard.optPictureNo.Value))
    StrBuildAutoTextName = strATName
    BuildAutoTextName_Exit:
    Exit Function
    BuildAutoTextName_Error:
    StrBuildAutoTextName = ""
    Resume BuildAutoTextName_Exit
    End Function
    'displays a tip during post-wizard options
    'assumes that Assistant is present since it is called from post-wizard balloon
    Private Sub DisplayTip(strTip As String)
    Dim objBlnTip As Balloon
    On Error GoTo FatalError
    Set objBlnTip = Assistant.NewBalloon
    With objBlnTip
    .Mode = msoModeModal
    .Heading = strWizName
    .Text = strTip
    .Button = msoButtonSetOK
    End With
    objBlnTip.Show
    If Assistant.BalloonError <> msoBalloonErrorNone Then GoTo FatalError
    Exit Sub
    FatalError:
    Err.Clear
    End Sub
    The above is from the module labelled "Calendar".  I don't believe anything was altered in the module labelled "Common", but please let me know that I should post it.
    To recap, in this wizard file, the first day of the week is set for Monday.  So the Saturday and Sunday columns always fall as the last 2 columns in the calendar table (Sunday as first day has the 1st and last column as the ones that would need shading).
    How can that syntax be added to shade the last 2 columns in the Monday calendar wizard, and the 1st and last column for the Sunday calendar wizard and hopefully shading just those particular cells in either with numbers in them?
    Thank you!  Very much appreciated. 

    Thanks, Doug!  Works beautifully.  I tried them again this morning, really incredible!
    I'm going to keep the Monday and Sunday wizard files as separate files because I realized that I don't have the skills (or the time) to try to figure out how to modify it so the user is requested the starting day.  It'll be beyond my meager skills,
    I'm sure, especially since there are all those dialogue boxes to contend with at the wizard's start.  I was forgetting about those.  So leaving these as 2 separate files where one chooses the starting day as per the title, the Monday one for Monday
    and the other, the Sunday one, for a Sunday start day.
    However, the only difference between them at this point is that one has a "0" for Sunday and the other a "1" for Monday, at the appropriate spots in the code.  being the starting week day and the other a "1" for Monday. 
    That's it.  They're beautifully the same in the rest of the code.  And a further benefit is that only one module was touched at all for all of this, the Calendar module (leaving the one labelled "Common" untouched.
    So anyone with a calendar wizard file can just change the piece of code below (begging the group's indulgence, if I may, in posting the modified code (??):
    ' WORD 97 WIZARD
    ' Calendar Wizard Specific Code
    Option Explicit
    ' CONSTANT DECLARATIONS
    '=============================== LOCALIZATION BLOCK ===============================
    ' Localization Note: iWeekStartDay is the starting day of the week (Sun = 0, Mon = 1, ...Sat = 6)
    Public Const iWeekStartDay As Integer = 1
    ' Banter strings
    Public Const strWarnYearReq As String = "Both starting and ending years are required."
    Public Const strWarnMinExceeded As String = "The year can not be before 1900."
    Public Const strWarnMaxExceeded As String = "The year can not be after 4095."
    Public Const strWarnRangeExceeded As String = "The calendar is limited to 120 months (10 years)."
    Public Const strAppCaptionPart1 As String = "Calendar: "
    Public Const strAppCaptionPart1b As String = ""
    Public Const strAppCaptionPart2 As String = ", "
    Public Const strAppCaptionPart3 As String = " to "
    Public Const strAppCaptionPart4 As String = ", "
    ' Status messages
    Public Const strStatusIntro As String = "Creating Calendar..."
    Public Const strStatusPart1 As String = "Creating "
    Public Const strStatusPart2 As String = ", "
    Public Const strStatusPart3 As String = "..."
    ' Assistant
    Public Const strCallBackHeading As String = "Do more with the calendar?"
    'Margins for A4 size (if wizard changes pagesize to A4)
    Public Const sA4_SHORT_MARGIN As Single = 28.8
    Public Const sA4_LONG_MARGIN As Single = 57.6
    'Margins for Letter size (if wizard changes pagesize to Letter) in pts
    Public Const sLETTER_SHORT_MARGIN As Single = 36
    Public Const sLETTER_LONG_MARGIN As Single = 36
    '========== END LOCALIZATION BLOCK - DO NOT MAKE CHANGES BELOW THIS LINE ==========
    Public Const iYearMin As Integer = 1900
    Public Const iYearMax As Integer = 4095
    ' Bookmark Names - DO NOT LOCALIZE
    ' Note: No spaces allowed in bookmark names
    Public Const strBkMkMonth As String = "Month"
    Public Const strBkMkDays As String = "Days"
    Public Const strBkMkDayNames As String = "DayNames"
    Public Const strBkMkYear As String = "Year"
    ' Calendar Style Names and Constants
    Public Const wzBOXES As Integer = 0
    Public Const wzBANNER As Integer = 1
    Public Const wzJAZZY As Integer = 2
    ' Form Control
    Public Const wzPAGE_START As Integer = 0
    Public Const wzPAGE_STYLE As Integer = 1
    Public Const wzPAGE_DIRECTION As Integer = 2
    Public Const wzPAGE_MONTHS As Integer = 3
    Public Const wzPAGE_FINISH As Integer = 4
    'orientation
    Public Const iORTN_PORTRAIT As Integer = 0
    Public Const iORTN_LANDSCAPE As Integer = 1
    ' Assistant
    Public Const iMAX_PANEL As Integer = 4 ' Number of last panel in MultiPage (First=0)
    Public Const iCALL_BACK_COUNT As Integer = 3 ' Number of items in CallBackBalloon (First=1)
    'postwizard balloon document variable
    Public Const strPOST_WIZ_BLN As String = "Calendar post wizard balloon"
    ' VARIABLE DECLARATIONS
    ' General
    Public rgstrMonthName(11) As String
    Public rgstrDayName(6) As String
    Public rgiDaysInMonth(11) As String
    Public fDateError As Boolean
    Public fCheckValidity As Boolean 'if set then the dates are checked for validity
    'variables used in doc. creation
    Public str1_TO_28 As String
    Public rgsDaysHeight(2, 1, 1) As Single
    Public rgsMonthNamesHeight(2, 1, 1) As Single
    Public rgstrDaysStyle(2) As String
    Public rgstrMonthNamesStyle(2) As String
    Public strSTY_BANNER_HDG3 As String
    ' Assistant
    Public rgstrAssistantMsg(iMAX_PANEL + 1) As String
    Public rgstrCallBackMsg(iCALL_BACK_COUNT) As String
    Public rgstrCallBackTip(iCALL_BACK_COUNT) As String
    ' Page 1
    Public iCalendarStyle As Integer
    Public iSavedStyle As Integer
    ' Page 2
    ' Page 3
    ' Page 4
    Public Sub InitWizardName(fDummy As Boolean)
    strWizName = "Calendar Wizard"
    strWizLongName = strWizName
    strWizShortName = "Calendar"
    End Sub
    Public Sub InitWizardStrings(fDummy As Boolean)
    Dim i As Integer
    On Error GoTo FatalError
    '=============================== LOCALIZATION BLOCK ===============================
    ' Note: this list is indexed 0 - iMAX_PANEL
    rgstrAssistantMsg(0) = "The Calendar Wizard helps you create a monthly calendar that you can customize with pictures and events. If you want to track and be reminded of events, you should probably use Microsoft Outlook, Microsoft Schedule+, or Microsoft Exchange."
    rgstrAssistantMsg(1) = "Select the look you want for your calendar. The Jazzy style uses the Algerian font. If it is not installed on your system, copy alger.ttf from the Valupack folder on the Microsoft Office CD to your hard drive."
    rgstrAssistantMsg(2) = "If you leave room for a picture, Word will insert a placeholder picture that you can replace with any picture you want."
    rgstrAssistantMsg(3) = "Your calendar can start on any month, and you can make your calendar shorter than or longer than 12 months. Each month will appear on a different page."
    rgstrAssistantMsg(4) = "To change any settings, click Back."
    ' Note: change constant iCALL_BACK_COUNT if number of items in list changes
    rgstrCallBackMsg(0) = "Add, remove, or replace a picture"
    rgstrCallBackMsg(1) = "Enter information into the calendar"
    rgstrCallBackMsg(2) = "Get Help on Something Else..."
    rgstrCallBackTip(0) = "To remove a picture, click on it and then press Delete. To add a picture, click where you want to insert the picture, point to Picture on the Insert menu, and then click From File."
    rgstrCallBackTip(1) = "To enter information, click where you want to insert the text and start typing. To move between different dates in the calendar, press Tab to move forward or press Shift+Tab to move to the previous date."
    'Load Month Name array
    rgstrMonthName(0) = "January"
    rgstrMonthName(1) = "February"
    rgstrMonthName(2) = "March"
    rgstrMonthName(3) = "April"
    rgstrMonthName(4) = "May"
    rgstrMonthName(5) = "June"
    rgstrMonthName(6) = "July"
    rgstrMonthName(7) = "August"
    rgstrMonthName(8) = "September"
    rgstrMonthName(9) = "October"
    rgstrMonthName(10) = "November"
    rgstrMonthName(11) = "December"
    'Load Day Name array LOCALIZATION NOTE: DO NOT CHANGE THE ORDER IN WHICH THESE APPEAR!
    ' TO CHANGE THE WEEK START DAY, CHANGE THE CONSTANT iWeekStartDay
    rgstrDayName(0) = "Sun"
    rgstrDayName(1) = "Mon"
    rgstrDayName(2) = "Tue"
    rgstrDayName(3) = "Wed"
    rgstrDayName(4) = "Thu"
    rgstrDayName(5) = "Fri"
    rgstrDayName(6) = "Sat"
    'Load Days In Month array
    rgiDaysInMonth(0) = 31
    rgiDaysInMonth(1) = 28 'Will not be used - must be calculated for leap year accuracy
    rgiDaysInMonth(2) = 31
    rgiDaysInMonth(3) = 30
    rgiDaysInMonth(4) = 31
    rgiDaysInMonth(5) = 30
    rgiDaysInMonth(6) = 31
    rgiDaysInMonth(7) = 31
    rgiDaysInMonth(8) = 30
    rgiDaysInMonth(9) = 31
    rgiDaysInMonth(10) = 30
    rgiDaysInMonth(11) = 31
    rgstrDaysStyle(wzBOXES) = "Boxes"
    rgstrDaysStyle(wzBANNER) = "Banner"
    rgstrDaysStyle(wzJAZZY) = "Jazzy"
    rgstrMonthNamesStyle(wzBOXES) = "Boxes Heading2"
    rgstrMonthNamesStyle(wzBANNER) = "Banner Heading2"
    'we dont set the style for month names in Jazzy style
    'the Banner style landscape calendar with picture uses Banner Heading3 style for month names
    strSTY_BANNER_HDG3 = "Banner Heading3"
    rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 0) = 55
    rgsMonthNamesHeight(wzBOXES, iORTN_PORTRAIT, 1) = 55
    rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 36
    rgsMonthNamesHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 36
    rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 0) = 56
    rgsDaysHeight(wzBOXES, iORTN_PORTRAIT, 1) = 102
    rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 0) = 72
    rgsDaysHeight(wzBOXES, iORTN_LANDSCAPE, 1) = 71
    rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 0) = 60
    rgsMonthNamesHeight(wzBANNER, iORTN_PORTRAIT, 1) = 60
    rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 55
    rgsMonthNamesHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 51
    rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 0) = 64
    rgsDaysHeight(wzBANNER, iORTN_PORTRAIT, 1) = 110
    rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 0) = 81
    rgsDaysHeight(wzBANNER, iORTN_LANDSCAPE, 1) = 81
    rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 73
    rgsMonthNamesHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 73
    rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 62
    rgsMonthNamesHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 59
    rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 0) = 40.5
    rgsDaysHeight(wzJAZZY, iORTN_PORTRAIT, 1) = 81.8
    rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 0) = 58.2
    rgsDaysHeight(wzJAZZY, iORTN_LANDSCAPE, 1) = 57.5
    str1_TO_28 = ""
    For i = 1 To 28
    str1_TO_28 = str1_TO_28 & CStr(i) & vbTab
    Next i
    'strip off last tab
    str1_TO_28 = Left$(str1_TO_28, Len(str1_TO_28) - 1)
    ' Location in registry DO NOT LOCALIZE
    strRegSettingsKey = strREG_SETTINGS_BASE_KEY & "Calendar Wizard"
    Exit Sub
    FatalError:
    ReportError Err
    End Sub ' InitWizardStrings
    Public Sub InitWizard(fDummy As Boolean)
    ' Global Vars
    fWizardCallBack = False
    fDateError = False
    iCurrentPanel = 0
    ' Initialize strings
    InitWizardStrings (True)
    ' Create a new instance of the form
    Set formWizard = New formWizDlg
    If formWizard Is Nothing Then GoTo FatalError
    formWizard.lblWizName1.Caption = " " & strWizLongName & " "
    Exit Sub
    FatalError:
    DisplayErrorMsg strERR_INIT_FORM
    ReportError Err
    End Sub
    ' fDummy prevents sub from appearing in Word Tools/Macro list
    Public Sub SaveDialogValues(fDummy As Boolean)
    On Error GoTo FatalError
    ' Display status
    Application.ScreenUpdating = False
    System.Cursor = wdCursorWait
    StatusBar = strSAVE_SETTINGS
    ' Assistant
    System.PrivateProfileString("", strREG_SETTINGS_BASE_KEY, strREG_ASSISTANT_TIME_STAMP) = Format$(Now, "General Date")
    StoreValPref strREG_ASSISTANT_HELP, iLocalState
    ' Page 1
    StoreValPref "iCalendarStyle", iCalendarStyle
    ' Page 2
    StoreValPref "optPortrait", formWizard.optPortrait.Value
    StoreValPref "optPictureYes", formWizard.optPictureYes.Value
    ' Page 3
    StatusBar = ""
    System.Cursor = wdCursorNormal
    fSettingsSaved = True
    Application.ScreenUpdating = True
    Exit Sub
    FatalError:
    ReportError Err
    End Sub
    Public Sub RestoreDialogValues(fDummy As Boolean)
    Dim i As Integer
    On Error GoTo FatalError
    ' Display status
    Application.ScreenUpdating = False
    StatusBar = strRST_SETTINGS
    System.Cursor = wdCursorWait
    ' Page 1
    iCalendarStyle = IRestorePref("iCalendarStyle", 0)
    Select Case iCalendarStyle
    Case wzBOXES
    formWizard.optBoxes.Value = True
    formWizard.shpShadowBoxes.Visible = True
    Case wzBANNER
    formWizard.optBanner.Value = True
    formWizard.shpShadowBanner.Visible = True
    Case wzJAZZY
    formWizard.optJazzy.Value = True
    formWizard.shpShadowJazzy.Visible = True
    Case Else
    iCalendarStyle = wzBOXES
    formWizard.optBoxes.Value = True
    formWizard.shpShadowBoxes.Visible = True
    End Select
    ' Page 2
    If FRestorePref("optPortrait", False) Then
    formWizard.optPortrait.Value = True
    formWizard.shpPortraitShadow.Visible = True
    formWizard.shpLandscapeShadow.Visible = False
    Else
    formWizard.optLandscape.Value = True
    formWizard.shpPortraitShadow.Visible = False
    formWizard.shpLandscapeShadow.Visible = True
    End If
    formWizard.optPictureYes.Value = FRestorePref("optPictureYes", False)
    ' Page 3
    formWizard.cboMonthStart.ListIndex = Month(Date) - 1
    formWizard.cboMonthEnd.ListIndex = Month(Date) - 1
    formWizard.txtYearStart = Year(Date)
    formWizard.txtYearEnd = Year(Date)
    fCheckValidity = False
    StatusBar = ""
    System.Cursor = wdCursorNormal
    fSettingsRestored = True
    Application.ScreenUpdating = True
    Exit Sub
    FatalError:
    ReportError Err
    Exit Sub
    End Sub ' RestoreDialogValues
    ' fDummy prevents sub from appearing in Word Tools/Macro list
    Public Sub CreateNewDoc(fDummy As Boolean)
    Dim iMonthCurr As Integer
    Dim iYearCurr As Integer
    Dim lYearMonthCurr As Long
    Dim lYearMonthEnd As Long
    Dim iDaysCnt As Integer
    Dim iDaysInMonth As Integer
    Dim iCnt As Integer
    Dim strAutoTextName As String
    Dim objTableDays As Table
    Dim iRow As Integer
    Dim iCol As Integer
    Dim ocboMonthStart As ComboBox
    Dim ocboMonthEnd As ComboBox
    Dim otxtYearStart As TextBox
    Dim otxtYearEnd As TextBox
    Dim strJazzyDayNames As String
    Dim objFps As PageSetup
    Dim objRng As Range
    Dim sShortMargin As Single
    Dim sLongMargin As Single
    Dim strCaptionTxt As String
    Dim iOrientation As Integer
    Dim iNoPicture As Integer
    Dim i As Integer
    Dim strDays As String
    On Error GoTo CreateNewDoc_Error
    System.Cursor = wdCursorWait
    Set ocboMonthStart = formWizard.cboMonthStart
    Set ocboMonthEnd = formWizard.cboMonthEnd
    Set otxtYearStart = formWizard.txtYearStart
    Set otxtYearEnd = formWizard.txtYearEnd
    With Application
    .ScreenUpdating = False
    .StatusBar = strStatusIntro
    End With
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Collapse wdCollapseEnd
    If (formWizard.optPortrait) Then
    iOrientation = iORTN_PORTRAIT
    Else
    iOrientation = iORTN_LANDSCAPE
    End If
    iNoPicture = Abs(formWizard.optPictureNo.Value)
    'the margins have to be changed if papersize was changed in Common
    If (fChangeToA4 Or fChangeToLetter) Then
    Set objFps = ActiveDocument.PageSetup
    If iOrientation = iORTN_LANDSCAPE Then
    objFps.Orientation = wdOrientLandscape 'setting paper size in common
    'resets orientation to Portrait
    If fChangeToA4 Then
    sShortMargin = sA4_SHORT_MARGIN
    sLongMargin = sA4_LONG_MARGIN
    Else
    sShortMargin = sLETTER_SHORT_MARGIN
    sLongMargin = sLETTER_LONG_MARGIN
    End If
    Else
    If fChangeToA4 Then
    sShortMargin = sA4_LONG_MARGIN
    sLongMargin = sA4_SHORT_MARGIN
    Else
    sShortMargin = sLETTER_LONG_MARGIN
    sLongMargin = sLETTER_SHORT_MARGIN
    End If
    End If
    With objFps
    .TopMargin = sShortMargin
    .BottomMargin = sShortMargin
    .LeftMargin = sLongMargin
    .RightMargin = sLongMargin
    End With
    End If
    strAutoTextName = StrBuildAutoTextName(True)
    objWizTemplate.AutoTextEntries(strAutoTextName).Insert objActiveRange, True
    If iCalendarStyle <> wzJAZZY Then
    Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDays).Range
    Else
    Set objActiveRange = ActiveDocument.Bookmarks(strBkMkDayNames).Range
    End If
    strJazzyDayNames = ""
    For iCnt = iWeekStartDay To 6
    strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
    Next
    For iCnt = 0 To (iWeekStartDay - 1)
    strJazzyDayNames = strJazzyDayNames & rgstrDayName(iCnt) & vbTab
    Next
    'Strip trailing Tab
    strJazzyDayNames = Left$(strJazzyDayNames, Len(strJazzyDayNames) - 1)
    objActiveRange.Text = strJazzyDayNames
    If iCalendarStyle <> wzJAZZY Then
    If (iCalendarStyle = wzBANNER) And (iOrientation = iORTN_LANDSCAPE) And (iNoPicture = 0) Then
    objActiveRange.Style = strSTY_BANNER_HDG3
    Else
    objActiveRange.Style = rgstrMonthNamesStyle(iCalendarStyle)
    End If
    objActiveRange.Select
    Selection.ConvertToTable wdSeparateByTabs, 1, 7
    End If
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Copy
    iMonthCurr = CInt(ocboMonthStart.ListIndex) + 1
    iYearCurr = CInt(otxtYearStart.Text)
    lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
    lYearMonthEnd = (CLng(otxtYearEnd.Text) * 100) + (CLng(ocboMonthEnd.ListIndex) + 1)
    'Create each month of the calendar
    Do Until lYearMonthCurr > lYearMonthEnd
    Application.StatusBar = strStatusPart1 & rgstrMonthName(iMonthCurr - 1) & strStatusPart2 & CStr(iYearCurr) & strStatusPart3
    'Set month
    If iCalendarStyle = wzJAZZY Then
    ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = CStr(iMonthCurr)
    Else
    ActiveDocument.Bookmarks(strBkMkMonth).Range.Text = rgstrMonthName(iMonthCurr - 1)
    End If
    'Set year
    ActiveDocument.Bookmarks(strBkMkYear).Range.Text = CStr(iYearCurr)
    'Determine number of days in month
    If iMonthCurr = 2 Then
    iDaysInMonth = DateSerial(iYearCurr, 3, 1) - DateSerial(iYearCurr, 2, 1)
    Else
    iDaysInMonth = rgiDaysInMonth(iMonthCurr - 1)
    End If
    'Set Column of First Day Of Month by using Weekday function. The 8th
    'is used (to start with) instead of the 1st to allow for offsetting (via
    'iWeekStartDay) for localization since the 8th will always fall on the
    'same day (of the week) as the 1st.
    iCol = WeekDay(DateSerial(iYearCurr, iMonthCurr, 8 - iWeekStartDay))
    ActiveDocument.Bookmarks(strBkMkDays).Select
    If iCalendarStyle <> wzJAZZY Then _
    Selection.MoveDown wdLine 'the bookmark is now in the first cell of the table
    strDays = ""
    For i = 1 To iCol - 1
    strDays = strDays & vbTab
    Next i
    strDays = strDays & str1_TO_28
    For i = 29 To iDaysInMonth
    strDays = strDays & vbTab & CStr(i)
    Next i
    'to get a 6 * 7 table always
    For i = iDaysInMonth + iCol - 1 To 41
    strDays = strDays & vbTab
    Next i
    Set objActiveRange = Selection.Range
    objActiveRange.Text = strDays
    objActiveRange.Style = rgstrDaysStyle(iCalendarStyle) & iOrientation & iNoPicture
    objActiveRange.Select
    Selection.ConvertToTable wdSeparateByTabs, 6, 7
    Selection.Cells.Height = rgsDaysHeight(iCalendarStyle, iOrientation, iNoPicture)
    Selection.Tables(1).Rows(1).Height = rgsMonthNamesHeight(iCalendarStyle, iOrientation, iNoPicture)
    '================================================================================================================================
    ' Tu.Mar.11.2015; 17h56 - MVPEdits/MyEdits
    ' SATURDAY and SUNDAY cells get shaded in the table (no matter where they fall).
    ' Doug Robbins - Word MVP; https://social.msdn.microsoft.com/Forums/office/en-US/6ab55be0-adc0-4e37-9565-8cdff089d20a/shading-certain-columns-depending-on-start-day-of-week?forum=worddev
    Dim j As Long
    With Selection.Tables(1)
    If iWeekStartDay = 1 Then
    For i = 6 To 7
    With .Columns(i)
    ' For j = 1 To .Cells.Count ' 1 = Cells with SAT and SUN text are shaded
    For j = 2 To .Cells.Count ' 2 = Cells with SAT and SUN text are _ NOT_ shaded
    With .Cells(j).Range
    If Len(.Text) > 2 Then
    .Shading.BackgroundPatternColor = wdColorGray20 'wdColorGray_ _ _ (the number following gives the shade of gray, i.e., wdColorGray20 vs. wdColorGray50)
    End If
    End With
    Next j
    End With
    Next i
    Else
    For i = 1 To 7 Step 6
    With .Columns(i)
    ' For j = 1 To .Cells.Count ' 1 = Cells with SAT and SUN text are shaded
    For j = 2 To .Cells.Count ' 2 = Cells with SAT and SUN text are _ NOT_ shaded
    With .Cells(j).Range
    If Len(.Text) > 2 Then
    .Shading.BackgroundPatternColor = wdColorGray20 'wdColorGray_ _ _ (the number following gives the shade of gray, i.e., wdColorGray20 vs. wdColorGray50)
    End If
    End With
    Next j
    End With
    Next i
    End If
    End With
    '================================================================================================================================
    '================================================================================================================================
    ' Mn.Sept.01.2014; 08h21 - MVPEdits/MyEdits
    ' TABLE GRIDLINES CODE: Automatically creates printable gridlines in the table.
    With Selection.Tables(1).Borders
    .InsideLineStyle = wdLineStyleSingle
    .InsideLineWidth = wdLineWidth100pt
    .InsideColorIndex = wdAuto
    .OutsideLineStyle = wdLineStyleSingle
    .OutsideLineWidth = wdLineWidth100pt
    End With
    '================================================================================================================================
    ActiveDocument.Bookmarks(strBkMkDays).Delete
    'Advance the current month
    If iMonthCurr = 12 Then
    iMonthCurr = 1
    iYearCurr = iYearCurr + 1
    Else
    iMonthCurr = iMonthCurr + 1
    End If
    lYearMonthCurr = (CLng(iYearCurr) * 100) + CLng(iMonthCurr)
    If lYearMonthCurr <= lYearMonthEnd Then
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Collapse wdCollapseEnd
    'Insert Page Break
    objActiveRange.InsertBreak wdPageBreak
    Set objActiveRange = ActiveDocument.Content
    objActiveRange.Collapse wdCollapseEnd
    objActiveRange.Paste
    End If
    Loop
    Application.StatusBar = ""
    strCaptionTxt = ""
    'Set Application caption
    strCaptionTxt = " - " & strAppCaptionPart1 & strAppCaptionPart1b & ocboMonthStart.Text & strAppCaptionPart2 & otxtYearStart.Text & strAppCaptionPart3 & ocboMonthEnd.Text & strAppCaptionPart4 & otxtYearEnd.Text
    ActiveDocument.UndoClear
    With ActiveWindow
    .Caption = .Caption & strCaptionTxt
    With .View
    .TableGridlines = False
    .ShowDrawings = True
    End With
    End With
    'Position cursor at the top
    Selection.HomeKey wdStory
    CreateNewDoc_Exit:
    Exit Sub
    CreateNewDoc_Error:
    ReportError Err
    GoTo CreateNewDoc_Exit
    End Sub ' CreateNewDoc
    Public Sub InitCallBack(fDummy As Boolean)
    Dim i As Integer
    Dim objCallBackLabels As BalloonLabels
    On Error GoTo ErrorCallBack
    If Not (fBlnInitialized) Then
    Set objPostWizBln = Assistant.NewBalloon
    fBlnInitialized = True
    With objPostWizBln
    .Heading = strCallBackHeading
    .Mode = msoModeModeless
    .Button = msoButtonSetCancel
    .BalloonType = msoBalloonTypeButtons
    .Callback = "Calendar.fnCallBack"
    End With
    Set objCallBackLabels = objPostWizBln.Labels
    objCallBackLabels.Count = iCALL_BACK_COUNT
    For i = 1 To iCALL_BACK_COUNT
    objCallBackLabels.Item(i).Text = rgstrCallBackMsg(i - 1)
    Next i
    End If
    objPostWizBln.Show
    If (Assistant.BalloonError) Then GoTo ErrorCallBack
    fPostWizBlnOpen = True
    Set objDocBln = ActiveDocument
    Set clsBln.app = Application
    ActiveDocument.Variables.Add strPOST_WIZ_BLN, "1"
    Exit Sub
    ErrorCallBack:
    DisplayErrorMsg strERR_INIT_CALL_BACK
    fPostWizBlnOpen = False
    Set objDocBln = ActiveDocument
    Set clsBln.app = Application
    ActiveDocument.Variables.Add strPOST_WIZ_BLN, "0"
    End Sub
    Public Function fnCallBack(objBln As Balloon, iBtn As Integer, lPrivate As Long)
    On Error GoTo ErrorCallBack
    Select Case iBtn
    Case Is < 1 'Exit
    objBln.Close
    fPostWizBlnOpen = False
    ActiveDocument.Variables(strPOST_WIZ_BLN).Value = "0"
    RestoreAssistant (True)
    Case 1 'Remove existing picture
    DisplayTip rgstrCallBackTip(0)
    Case 2 'Enter information into calendar
    DisplayTip rgstrCallBackTip(1)
    Case 3 ' Get help
    Assistant.Help
    End Select
    Exit Function
    ErrorCallBack:
    DisplayErrorMsg Err.Description
    End Function
    Private Function StrBuildAutoTextName(fDummy As Boolean) As String
    Dim strATName As String
    On Error GoTo BuildAutoTextName_Error
    'Select base AutoText Name NOTE: DO NOT LOCALIZE
    Select Case iCalendarStyle
    Case wzBOXES
    strATName = "Boxes"
    Case wzBANNER
    strATName = "Banner"
    Case wzJAZZY
    strATName = "Jazzy"
    End Select
    strATName = strATName & CStr(Abs(formWizard.optLandscape.Value))
    strATName = strATName & CStr(Abs(formWizard.optPictureNo.Value))
    StrBuildAutoTextName = strATName
    BuildAutoTextName_Exit:
    Exit Function
    BuildAutoTextName_Error:
    StrBuildAutoTextName = ""
    Resume BuildAutoTextName_Exit
    End Function
    'displays a tip during post-wizard options
    'assumes that Assistant is present since it is called from post-wizard balloon
    Private Sub DisplayTip(strTip As String)
    Dim objBlnTip As Balloon
    On Error GoTo FatalError
    Set objBlnTip = Assistant.NewBalloon
    With objBlnTip
    .Mode = msoModeModal
    .Heading = strWizName
    .Text = strTip
    .Button = msoButtonSetOK
    End With
    objBlnTip.Show
    If Assistant.BalloonError <> msoBalloonErrorNone Then GoTo FatalError
    Exit Sub
    FatalError:
    Err.Clear
    End Sub
    Thank you once again for all your help!!  Very much appreciated.  :D

  • Display two different column types in cross tab

    I am using Cross Tab template in crystal XI and I have to show two different column types one is of type int and other is of type string. Below is the format of the report
                                  AmountGiven             Amount Spent            Attended
    Mike                       5000                              3000                         Yes
    Steve                     200                                 200                           No
    Is there a way I can do this showing "yes" or "no" in the third column???
    Thanks...

    Hi
    If you are trying to show "yes" or "no" for a column value in a cross tab, then yes we can try using a formula for it.
    I would suggest you 2 ways that you can try at your end:
    1.
    a) Create a formula in the cross tab expert and write your condition.
    for eg: if Sum({Orders.Order amount}) > 5000 then "yes" else "no"
    b) Then select that formula in the summarized fields in cross tab expert and change the summary to MODE.
    c) You can see the "yes" and "no" Within the same box.
    2.
    a) Add a field to the colums in the cross tab expert.
    b) A column gets inserted in the cross tab.
    c) Right click the field and select format field.
    d) Go to Common tab and write a formula for the display string.
    e) Write the condition in that formula.
    f) You can see a new column with the expected values.
    Hope this helps you..
    Please revert incase of any queries.
    Regards
    Pradeep Hulke

  • Design a single template for multiple reports with different column order

    Hi,
    I need to migrate the existing reports from SQL Server Reporting Services to Crystal Report 2008, and the column order in the report is very important to the clients since clients have existing code to ingest these reports into their database. Now I want to create a single template with lot of parameters for all reports. My question is how I might use one template to create multiple reports with different column orders in the reports?
    For example, client A has the following column order in their report: firstName, LastName, DateBirth, SSN. Client B has the following column order in their report: SSN, DateBirth, LastName, FirstName. Can I use one template to create these multiple reports?
    Thanks in advance.

    -As I mentioned you can find Template Field object in Insert menu of crystal report Designer 2008.
    As soon as you select Template Field object you will be able to see a box beside ur mouse cursor. Drag and drop this box at required place. Now when you place this object in report you will get some thing like this "<TemplateField1>" listed under Formula Fields tree. Double click "<TemplateField1>" formula to add your conditions.
    -I have not tested it for large amount of Customers. However as the number of customer increases the number of conditions will get increased.
    For the customer that want the same ordering of columns you can put those customers under one condition.
        for Example...
              if(?Client in ['clientA','clientA']) then
                        <TableName>.<Field>......
    -What do you mean be 40 columns? Do you mean 40 fields or you want to show 40 columns in report? Please elaborate.
    Regards,
    Amrita
    Edited by: Amrita Singh on May 21, 2009 7:54 AM

  • Breaking the string into different columns

    Hi Guys,
    I need to break the following string into different columns
    'XXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007.'
    I am trying to write it using instr and substr , but having some issues .
    Is there any other way to do this. If not can someone help me , below is the query that i am working on
    SELECT SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', 1, INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1) - 1) col1,
    SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007',
    INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1) + 1,
    INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1, 2)
    - INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', 1)
    - 1
    ) col2,
    SUBSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007',
    INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 2) + 1,
    INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 1)
    - INSTR ('XXXXXX.0001.09011.0001.00002.03.0004.0005.0006.00007', '.', -1, 2)
    - 1
    ) col3
    from dual
    It is very urgent.
    Thanks in advance.

    npejavar wrote:
    It is very urgent.
    It doesn't look urgent, you could simply read the manuals for instr and substr or describe any issues or errors you are having, or post sample data so people could help you more easily, or format your code so it is more readable, but you don't bother to do any of those things so if it isn't important to you to extend any effort, why would it be important to us?
    If it was really urgent it would be a violation of the conditions of use of these forums.
    http://www.catb.org/esr/faqs/smart-questions.html#urgent
    http://www.oracle.com/html/terms.html
    >
    4. Use of Community Services
    Community Services are provided as a convenience to users and Oracle is not obligated to provide any technical support for, or participate in, Community Services. While Community Services may include information regarding Oracle products and services, including information from Oracle employees, they are not an official customer support channel for Oracle.
    You may use Community Services subject to the following: (a) Community Services may be used solely for your personal, informational, noncommercial purposes; (b) Content provided on or through Community Services may not be redistributed; and (c) personal data about other users may not be stored or collected except where expressly authorized by Oracle

  • How to get multiple records in one row and different column

    Hi All,
    I am using oracle database 11g
    and i have a two tables table_1, table_2
    table_1 having columns
    emp_no
    first_name
    middle_name
    last_name
    email
    and table_2 having columns
    emp_no
    phone_type
    phone_number
    and having entires
    emp_no phone_type phone_number
    1001 MOB 9451421452
    1001 WEMG 235153654
    1001 EMG 652341536
    1002 MOB 9987526312
    1003 WEMG 5332621456
    1004 EMG 59612356
    Now i want the output of values with phone type as MOB or WEMG in a single row with different columns
    emp_no first_name middle_name last_name email mobile officeno
    1001 mark null k [email protected] 9451421452 235153654
    1002 john cena gary [email protected] 9987526312 null
    1003 dany null craig [email protected] null 5332621456
    1004 donald finn sian [email protected] null null
    can i have any inputs to achive this???
    Regards
    $sid

    Frank Kulash wrote:
    sonething like this:Frank, you missed aggregate function (pivot requires one). However main thing is it will cause ORA-01748:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k'last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
    SELECT     *
    FROM     table_1      t1
    JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    PIVOT     (    max(t2.phone_number)
         FOR  t2.phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
            FOR  t2.phone_type  IN  ( 'MOB'   AS mob
    ERROR at line 19:
    ORA-01748: only simple column names allowed hereYou need to:
    with table_1 as (
                     select 1001 emp_no,'mark' first_name,null middle_name,'k' last_name,'[email protected]' email from dual union all
                     select 1002,'john','cena','gary','[email protected]' from dual union all
                     select 1003,'dany',null,'craig','[email protected] null' from dual union all
                     select 1004,'donald','finn','sian','[email protected]' from dual
         table_2 as (
                     select 1001 emp_no,'MOB' phone_type,9451421452 phone_number from dual union all
                     select 1001,'WEMG',235153654 from dual union all
                     select 1001,'EMG',652341536 from dual union all
                     select 1002,'MOB',9987526312 from dual union all
                     select 1003,'WEMG',5332621456 from dual union all
                     select 1004,'EMG',59612356 from dual
         table_3 as (
                     select  t1.emp_no,first_name,middle_name,last_name,email,
                             phone_type,phone_number
                       FROM     table_1      t1
                       LEFT JOIN     table_2      t2  ON  t1.emp_no = t2.emp_no
    SELECT     *
    FROM     table_3
    PIVOT     (    max(phone_number)
         FOR  phone_type  IN  ( 'MOB'   AS mob
                                 , 'WEMG'  AS wemg
        EMP_NO FIRST_ MIDD LAST_ EMAIL                     MOB       WEMG
          1004 donald finn sian  [email protected]
          1003 dany        craig [email protected] null            5332621456
          1001 mark        k     [email protected]      9451421452  235153654
          1002 john   cena gary  [email protected]    9987526312
    SQL>SY.

  • How do I select multiple columns in a recordset

    I am very new to Dreamweaver/PHP/MYSQL
    I have created my recordset but I cant work out how I select multiple columns.
    How do I select multiple columns, I want to search for data that is spread over different columns.
    My recordset looks like this just now.
    SELECT *
    FROM names
    WHERE nameone = john
    I have 11 columns where the name john my or may not appear so how would I select all the columns. What would the recordset look like.
    As I have said I,m very new to this  and forgive me if what i have just said makes no sense.
    Thanks

    >I have 11 columns where the name john my
    >or may not appear so how would I select all
    >the columns. What would the recordset look like.
    You could try a Full-Text search (if mysql supports it) but on the surface, this sounds like a badly designed data structure. What does your database and table design look like?

  • What is the difference betwwen SELECT ALL Column and Select Speceific Colum

    Hi All,
    If the block size of the database is 8K and average row length is 2K and if we select all column of the table the I/O show that it had read more blocks then compare to
    specific column of the same table. Why is this?
    Secondly if Oracle brings a complete block is the db buffer cache, while reading block from disk, they why there is a difference of block count in two queries.
    This difference reveals to me when I check the EXPLAIN PLAN for two different queries against the same table but one select all columns and the other one select specific column.
    Kindly help me in clearing this confusion.
    Regards,
    Kamran

    user1514587 wrote:
    >
    Usually, indexes are smaller (contain fewer blocks) than the table - ergo, select empno from emp could be satisfied by reading fewer blocks.
    what if there is a composite Index on a table containing 3 to 4 columns and the size of table is in 100 of GB and Index size itself is vey large then I think Oracle will go for FTS and small Index scan will be expensive. Kindly Share your thoughts.
    Regards,
    KamranHandle:     user1514587
    Status Level:     Newbie (5)
    Registered:     May 9, 2011
    Total Posts:     21
    Total Questions:     13 (12 unresolved)
    I think you wastes everyone's time here since you rarely get answer to any posted question

Maybe you are looking for

  • Beginner in Acrobat 9 Pro

    Hi, I'm just trying acrobat 9 pro. What I want to do is put in a .flv onto a page with text and make an ebook of 30 pages with a .flv on each page. My question is: Once everything is on a page, how do I modify it? I'd like to make the .flv smaller an

  • Null Exception when XSL Files longer than 8192 char

    javax.servlet.jsp.JspException: Error applying stylesheet stylesheets/Sds.xsl 8192 This is the error message obtained where transforming applying an XSL sheet longuer then 8K ! How can we use XSL files > 8k ?? Context: Oracle9iAS (9.0.3.0.0) Containe

  • Keyboard shortcuts in CS4 won't work! Please help!

    In the last month I have lost all of my keyboard shortcuts in my CS4 program.  I was using Windows Vista Professional - and installed CS4 in August.  Everything was working great.  Then last month, all of the shortcuts disappeared.  I uninstalled/the

  • Re: Vertical Scroll Bar on the device display

    Hello. we are also facing the following issue. I was able to control the horizontal spacing with SICF parameters ~ITSMOBILEELEMFACTOR = 8 ~ITSMOBILEELEMUNIT = px However, I have tried quite a few different ways of reducing the vertical spacing. Nothi

  • Variable in SAP SCRIPT

    Hi Guys, I want to print a variable Value from Print Program to SAP SCRIPT, I tried to print it in between && but they still dont have any value while debugging SAP SCRIPT and not also in print out....Suggest somthing. Cheers....!! Sid