Results 1 to 22 of 22

Thread: {Resolved}Problem with Word-Bookmark with VB.NET

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2004
    Posts
    369

    {Resolved}Problem with Word-Bookmark with VB.NET

    Hi,

    This is the code I execute in a loop. For example ... this will be run 3-4 times to loop in a dataset.


    VB Code:
    1. objWord = CreateObject("Word.Application")
    2. objWord.ActivePrinter = "My Printer Name"
    3. objWord.Visible = False
    4.  
    5. Select Case strDocument
    6.     Case ANNEXEAF
    7.         With objWord
    8.             .Documents.Open("C:\Projets\\MyDocument.dot")
    9.  
    10.             .ActiveDocument.Bookmarks.Item("siPOCKET").Select() 'word doc bookmark
    11.             .Selection.Text = clsClass.NoPermis
    12.  
    13.             .ActiveDocument.Bookmarks.Item("siDATE").Select() 'word doc bookmark
    14.             .Selection.Text = clsClass.DateInfrac
    15.  
    16.             .PrintOut(Copies:=1, Collate:=True, Background:=True, PrintToFile:=False)
    17.  
    18. 'Wait for document to print
    19.             Do While .BackgroundPrintingStatus > 0
    20.                 Application.DoEvents()
    21.             Loop
    22.  
    23.             .Documents.Close(Word.WdSaveOptions.wdDoNotSaveChanges)
    24.         End With


    For the 1st document it's ok.
    But then it kind of freeze. When I run it line by line (debugging), the application goes fine.
    But if I'm not in debug mode, something is going wrong. The only thing I can see is the Do While .BackgroundPrintingStatus loop.

    I have to move the mouse or do something else on my PC to make to program continue between each document to print.

    And my application window "flikkles" .. as if we were seeing a Word window open, but I want that to happen in the background.


    Thanks for helping !
    Last edited by dbelley_office; Mar 18th, 2005 at 09:23 AM. Reason: problem resolved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width