word automation with C#

Last post 07-20-2008 1:24 AM by prashant121. 1 replies.

Sort Posts:

  • word automation with C#

    07-19-2008, 1:00 AM
    • Loading...
    • prashant121
    • Joined on 07-19-2008, 12:36 AM
    • Posts 2

    Hi all,

    Recently I got one requirement, to prepare word & excel file through automated batch process. I am new to working with word using C#

    Here is my steps & problem... Please guide me.

    1) I have word template file (.dot) file
    2) I have couple of predefine bookmarks in this template (.dot) file
    3) From c# I am opening this template and replacing bookmarks value with actual value

    For example following are my bookmark in (.dot) file (template file)
    A_B_C_D                                    P_Q_R
    C_Y_T_Z                                     R_V_N
    R_M_W_Q                                  J_E_K


    now based on condition i am putting different value for these
    bookmark. Also I am checking if the
    actual value for "P_Q_R" bookmark is null I am checking actual value for "R_V_N" bookmark
    and replacing actual value of  "A_B_C_D" with "C_Y_T_Z" & "P_Q_R" with "R_V_N" respectively

    Now  based on my left side bookmark actual text length the right side alignment not coming properly. 

    for example

    Hello h r u                        100.55
    fine                              54.12
    C# programming                       102.85
    something here if too long                         211.53

    I dont want to use table


    Highly appreciate your help & any suggestion; I am really stuck with
    this problem,

     

    thanks a lot
    pbrathod

  • Re: word automation with C#

    07-20-2008, 1:24 AM
    • Loading...
    • prashant121
    • Joined on 07-19-2008, 12:36 AM
    • Posts 2

    here is the detail explanation...

     

    The problem with formatting while replacing bookmark value. Alignment is not proper.

    I will try to explain the problem...

    suppose following are bookmarks in  'example.dot' file

    A_B_C_D (bookmark1)                                             R_S_T (bookmark2)

    E_F_G_H (bookmark3)                                             P_Q_R (bookmark4)

    I_J_K_L (bookmark5)                                                 N_O_P (bookmark6)

    ...........

    ...........

    here is our Hashtable Key/Value

    Key                              Value

    102.50                        You used service A

       85.29                        Service is not available is different charge

         6.99                        Installation charge

         0.99                         Let fee

    Now i am going to replace Left side bookmarks text (1,3,5)  with above Hashtable values and right side bookmarks text (2,4,6)  with above Hashtable keys.

    left side bookmarks text (1,3,5) comes proper way, but right side bookmarks text (2,4,6) alignment not coming properly. sometime its little left & some time little right, & this is because of left side bookmarks text (1,3,5) length.

    Can we fixed the bookmarks position in .dot file?

    thanlk you,

    Prashant

Page 1 of 1 (2 items)
Microsoft Communities
Page view counter