Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    "Invisible" Word objects

    (I have divided this up into 3 sections: Background, Problem, and Question(s))

    Background:
    I have this macro which has to take a report and split all the entries up into 5 different reports.

    I have created a Word object called wrdApp to help deal with the task a little better.

    I found that there is a lot of screen activity in swapping between the documents and the "ScreenUpdating = False" doesn't quite give the desired results.

    I then discovered I could use the following statement: wrdApp.Visible = False.

    The statement wrdApp.Visible = False hides all action with Word documents created and dealt with by the object wrdApp, which is just perfect with me.

    Problem:
    The original document which is not opened or created by the wrdApp object also becomes "invisible" and I cannot show any messages to tell the users the VBA macro is still busy.

    Question(s):
    1) Is there a way to somehow have Word display a form or something similar, yet still keep the Word objects "invisible"?
    2) Is there another method or avenue that would have the same or similar effect to "wrdApp.Visible = False"?

    Thanks for your thoughts and comments in advance.....

    James

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: "Invisible" Word Objects

    Are you working with Word 97 or Word 2000?

    In Word 97 you can use a trick that involves minimizing the ActiveWindow (I used to do this with only one document open; probably could do it with multiple documents open), so that effectively all you see is the Word app background and the large gray area that you see when no documents are open.

    You can have a userform display in the gray area, and update messages onto the userform to keep the users informed of progress. Then when everything is done, unload the userform and restore the ActiveWindow to full size.

    In Word 2000 this trick doesn't appear to be easily available.... If you are working on Word 97 and want some tips on implementing the above method, I can probably dredge up some relevant code from my Word 97 install at work, let me know.

  3. #3
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: "Invisible" Word objects

    hi,

    I'd say this depends on what you are doing in the first place.

    If you are doing a lot of swapping betweeen documents, thenm it's possible you are doing lots of cut and paste operations- using the "selection" object.

    If that's the case, then you can make your operations a lot more seemless by using a range object.

    eg- where "CopyHere" is a bookmark in your destination document:

    <pre>Dim rngFrom As Range
    Dim rngTo As Range

    Set rngFrom = Documents("Document1").Range
    Set rngTo = Documents("Document2").Bookmarks("Copyhere").Range
    rngTo.Text = rngFrom.Text
    </pre>


    I'm on record in this forum as being a fan of "rnage" vs "selection". Range does not physically swap a page display- so it's far more efficient (depending on what you're trying to do) than Copying into a selection from one document, swapping to the other document, and then pasting.

    Gary's <A target="_blank" HREF=http://www.wopr.com/cgi-bin/w3t/showthreaded.pl?Cat=&Board=vb&Number=6841&page=&vi ew=&sb=&vc=1#Post6841>response to an earlier thread</A> is very good on the topic.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: "Invisible" Word Objects

    Hi there, Gary.

    I'm using Office 2000. Thanks for the tips, I can see that it will work well in Word 97 as it is uses the multiple document interface (MDI).
    Unfortunately you are correct about it being tricker in Word 2000 as it uses single user interface.

    I have tried the minimize option, yet there is still a bit of screen activity which I would like to get rid off.

    Thanks for the tips anyway.

    James

  5. #5
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: "Invisible" Word objects

    Hi there, Geoff.

    Thanks for your response, but I have gone through the "range" vs "selection" topic before.

    The posting is on a totally diffent issue. Please refer to the "Problem" and "Question(s)" sections under the original posting for further details

    James

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re:

    Hi James,

    The only approximation I've been able to work out so far in Word 2000 is to reduce the zoom size of the document view while the processing is taking place, then restore it when finished.

    If you reduce it too much though, then multiple pages display at a time and Word has a lot of work redrawing them. At about 60% zoom though, it just seemed like a bit less screen drawing was going on.

    Another thing you might try is to keep the userform visible during the processing, and to make it almost as large as the Word app window! - that probably won't speed anything up, but will spare the users from having to see the mayhem going on in the background. You could treat them to a little slide show on the userform to entertain them while they wait <g>

    Gary

  7. #7
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: "Invisible" Word objects

    James,

    My apologies if my answer did not fit you situation. I was only trying to address the problem of the screen swapping- which goes further back than your problem.

    I'd be interested to know what you were trying to do, and why so much screen swapping has been happening. Could reducing that swapping help your problem- without trying to do too many other things with Word?

    Just a thought.
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  8. #8
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re:

    Hi Geoff,

    It's nice to be quoted, I guess: you would quote that post since I made so many concessions to your point of view![img]/w3timages/icons/laugh.gif[/img]

    Seriously though I feel like sticking up for the good ole Selection object - there's still lots of mileage left in the trusty old vehicle yet (kind of like my '85 Chevy Caprice) and sometimes it's really the best way to travel - nothing to get defensive about, I say (and now you can supply the "Range Rover" analogy[img]/w3timages/icons/grin.gif[/img]

  9. #9
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: "Invisible" Word objects

    Basically, there is a Word document containing 1 line entries for some event actions performed while processing reports.

    The manager/director wishes to see a seperate report for each of the 5 categories.

    I have optimized the code as far as possible to minimize document swapping, I am now finsihed withe the processing and now I am working on astetics (what the user sees on the screen).

    I may be trying to do too many things with Word, but I am sitting on a temporary computer in Tokyo, Japan with minimal tools; while my computer is sitting partially assembled in Singapore, with most of the relevant development tools on my computer in Singapore.

    James

  10. #10
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re:

    A slide-show isn't too bad an idea. Speed is not an issue anymore with my code. I'll bet my bottom-dollar that it'll take one of Microsoft's permanent deep-level VB(A) programmers too speed it up significantly. (The alternative to this code takes about 2 or 3 hours longer and costs about 4 to 6 times more)

    James

  11. #11
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re:

    Gary, I had a quick thought.

    Is it possible for subroutine 1 to call subroutine 2 and for the rest of subroutine 1 to complete running while subroutine 2 is in progress. (Thereby having 2 "threads" running at the same time.)

    [Code example:

    Sub Number1
    'code goes here

    Call Sub Number2

    'more code goes here
    End Sub

    Sub Number2
    'Number2's code
    End Sub

    End Code]

    Is this possible in VB or VBA?

    James

  12. #12
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re:

    James,

    At least with VBA, I don't think that is possible, since there is only one 'processing space' (not sure what the correct term is).

    You'll have to get a VB person to confirm, but I'd imagine you can do multithreaded processing using VB.

    Gary

  13. #13
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re:

    An alternate way to design this, though probably a bit late for you, would be to first sort the lines into the 5 categories. Depending on the layout of your data, this could take some doing. In one project, I insert a sortable string in hidden text at the beginning of each line, then sort, then replace all hidden text with nothing. Another approach would be to simply move the data within the same file to a new section for each report.

  14. #14
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: "Invisible" Word objects

    Hi James,
    How have you initialised wrdApp? If you use
    Dim wrdApp as New Word.Application
    you can make it invisible without affecting your current document as you're running 2 separate instances of Winword.exe.
    Does that help?
    Regards,
    Rory

    Microsoft MVP - Excel

  15. #15
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington (Greater Manchester area)/Cheshire, UK
    Posts
    153
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: "Invisible" Word objects

    Hi there, Rory

    I had initialized is just as Word.Application. Initializing it as New Word.Application solved the problem.

    Just I have a little problem with one of my range statements now:
    wrdApp.Documents(wrdApp.ActiveDocument.Name).Bookm arks("doc").Range.FormattedText = _
    StatementList(Count).myRange.FormattedText

    Previously the above mentioned code work, but now I get an error message, Error 4618 - Type mismatch (if I remember correctly). The StatementList is an array containing an ID number and a range.

    I now have the following code which works (only problem is that it is slower):
    StatementList(Count).myRange.Copy
    wrdApp.Documents(FileName(UBound(FileName))).Bookm arks("doc").Range.Paste

    Any ideas on why my original code doesn't work, just because I changed the initialization of the Word object? Or is there something I am missing?

    Thanks for the help so far!

    James

Page 1 of 2 12 LastLast

Posting Permissions

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