Announcement

Collapse
No announcement yet.

Bullet Points created programatically for Word 2002 don't work in Word 2007

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bullet Points created programatically for Word 2002 don't work in Word 2007

    Hi All,

    I am a new member. I just registerred myself as I have a problem.

    I try to describe it briefly:

    I am working on a Visual Foxpro application that creates some cover letters for reports using Mail Merge.

    Our computers got upgraded recently and Word 2007 doesn't seem to handle the Bullet Points very well. (Word 2002 was used previously)

    The code is not simple , so I can't really cut and paste in here, but it works fine for years on Word 2002.

    The Word Document and Bullet Points are created programatically. (values come from a table/memo field)

    I try to paste the relevant code below from different methods and classes:

    Crepadviseletterind.word()

    this.oWord = CREATEOBJECT("Word.Application")

    *-- Open the template
    this.oWord.Documents.add(vcTemplate)

    *-- Get a reference to the Word document
    loTemplate = this.oWord.activeDocument

    *-- Execute any specific action over the tamplate before
    * merging the document with the data
    llReturn = this.preMergeAction(@loTemplate)

    then =>

    cdoclayout.formatworddocument()=>cdoclayout.format bookmark - this is where bullet points are added to the document

    vcBookmark = “BulletPnt1”

    WITH this.oWord.ActiveDocument
    IF .Bookmarks.Exists(m.vcBookmark)
    .Bookmarks(m.vcBookmark).Select()

    .ActiveWindow.Selection.Font.hidden = .f. && this must be set before the next line otherwise it appears to have no effect in Word
    .ActiveWindow.Selection.TypeText(m.vcText) && this is the text that gets displayed under a bullet pint

    ELSE
    llReturn = .f.
    ENDIF
    ENDWITH

    I traced through the code but I didn't notice anything strange, which is logical as it runs fine on Word 2002:

    There are 4 Bullet Points created and the above code runs 4 times.

    When I finally run Execute :


    *-- Finally, merge the documents
    loTemplate.Activate()
    loTemplate.MailMerge.execute()

    The document is displayed with 8 Bullet points as displayed below:
    • [BulletPnt1 Bookmark]
    • [BulletPnt2 Bookmark]
    • forward a consolidated tax statement for taxation purposes after the end of each financial year;
    • send detailed financial statements on your Fund within two months after the end of the year to 30 June;
    • [BulletPnt5 Bookmark]
    • [BulletPnt6 Bookmark]
    • [BulletPnt7 Bookmark]
    • [BulletPnt8 Bookmark]
    The text from BulletPnt1 and 2 is missing (replaced with
    <LI class=MsoNormal style="MARGIN: 0cm 0cm 3pt; mso-list: l0 level1 lfo1; tab-stops: list 36.0pt">[BulletPnt1 Bookmark])The texts from BulletPnt3 and 4 is displayed as expected
    And there are 4 other Bullet Points displayed as above. (5-6-7-

    I searched through the threads, but I couldn't find any solution to the above problem.

    I need to find a solution that runs on both Word 2002 and Word 2007 as the same application runs on different worstations.

    My experience with Programatically manage Word is close to zero.

    I had a look at the latest Word Object Model and it gone through changes by the sound of it. But I couldn't really find any solution to my problem.

    Any help/idea would be really appreciated.

    Thanks a lot,

    Judith

  • #2
    Re: Bullet Points created programatically for Word 2002 don't work in Word 2007

    From experience, only the simplest macros run correctly in Word 2007 and previous versions -- a lot has changed

    Can you post (ok, not the whole code) but any more than the fragments you have done

    Have you tried recording a new word macro to select/insert the bullet points to see how 2007 codes it?
    Tom Jones
    MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
    PhD, MSc, FIAP, MIITT
    IT Trainer / Consultant
    Ossian Ltd
    Scotland

    ** Remember to give credit where credit is due and leave reputation points where appropriate **

    Comment


    • #3
      Re: Bullet Points created programatically for Word 2002 don't work in Word 2007

      Ossian,
      Thank you for yourfeedback and the idea to record Macros in Word. I didn't know about that possibility and I wouldn't have thought about it.
      It didn't solve my problem, but it helped me to recreate the issue is a small PRG, separated from the big aplication.

      The above code is kind of "complete", not much to add there, but what wasn't complete is the bookmarks.

      The document is created from a template that has 13 bookmamarks including the magic 8 bullet poin items.
      I think that the confusion comes from the fact that 10 of these bookmarks are "overlapping" (pointing to the same position) Therefore the first two Bullet Point items get written to a wrong position (outside of the bullet point section) while the rest goes to the right place.

      The attached template and prg is a very simplified version of the code and it is fully reproducing the issue. (I got rid of the Mail merge factor)

      Somehow Word 2002 seems to hande this all right.

      If I run the same code using Word 2007 I get the problem. It is all good in Word 2002.

      Also it looks like in Office 2007 the test is inserted inside the bookmark. []

      This is how far I got. I don't have the solution, but I am getting closer, I think.

      I am only a basic Word user that doesn't help, but i am working on it.

      Any help is appreciated, but otherwise I will post the solution (ifi I findn it)

      Thanks a lot.

      PS: coverletter-jb is a .dot file while jbword.txt is a .prg file. (I couldn't attach otherwise)
      Attached Files

      Comment


      • #4
        Re: Bullet Points created programatically for Word 2002 don't work in Word 2007

        Thanks for your input.
        I found the solution to the problem, so I thought to share it in case if someone else will need it one day.

        It is kind of weirld as it shouldn't be a problem at all.

        Basically what happens: I have a template with some "Overlapping" Bookmarks: one Header , eight bullet points and a Footer.

        All these bookmarks are pointing to the same position and some of them may not be used. (it is all data driven)

        The issue is that in Office 2007 when the Bookmark is located and text inserted the place of the bookmark is not located properly. ord 2007 gets confused. (Word 2002 is handleing this fine)

        So I should have:

        Header
        - BulletPoint1
        - BulletPoint2
        - BulletPoint3
        - BulletPoint4
        - BulletPoint5
        - BulletPoint6
        - BulletPoint7
        - BulletPoint8
        Footer

        These entries may not be populated in this order.
        When BulletPoint entries are inserted, some goes to the Footer. And the comments of the unused bookmarks are made visible. (as per my attachment)

        The solution is to make sure that Word has the "Show Paragraph Marks and other Hidden Symbols" ON.

        When Hidden symbols are displayed the locate works fine.

        Word 2002 as no issues locateing the right bookmarks regardless of any settings.

        The solution is a line of code:

        this.oWord.ActiveWindow.ActivePane.View.ShowAll = .T.

        or three as I saved the existing setting and restored at the end. (once the document is formatted)

        Ossian, thanks for the idea of the macro recording. It helped me to find the right property.

        Judith

        Comment


        • #5
          Re: Bullet Points created programatically for Word 2002 don't work in Word 2007

          Thanks for posting back with the fix
          Rep++
          Tom Jones
          MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
          PhD, MSc, FIAP, MIITT
          IT Trainer / Consultant
          Ossian Ltd
          Scotland

          ** Remember to give credit where credit is due and leave reputation points where appropriate **

          Comment

          Working...
          X