Results 1 to 6 of 6
  1. #1
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Opening Word from SQL (WinXP OXP)

    We are in the process of developing a new business system that includes using an SQL database. One of the requirements is that at the end of a job a report is generated. Our developers have taken our standard report template which they open in Word and populate with the appropriate data from the SQL database.

    We have a small problem in that the job may have been carried out at a different address from that which is populated to the report. In an attempt to overcome this I have written some VBA code to ask if the report populated is the correct one. If it isn't an input box pops up allowing the address to be changed.

    The problem is there is a big, 15-20 seconds, delay until Word actually opens and this causes the dialogue box asking "Is this the correct address?" to open before Word has opened and appears to cause a delay in Word opening.

    My intuition tells me I should put a delay in the AutoOpen module to allow Word to open properly before intialising the dialogue box, but I am not sure.

    Can anyone help?

    Cheers
    cheers

    Phil Carter

  2. #2
    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: Opening Word from SQL (WinXP OXP)

    Phil, can you explain the way you've distributed the code a bit more? For example, you have an AutoOpen macro. Where is this stored - in the blank report template from which you are creating a new report document? Is your code to pop up the MsgBox in that macro?

    Assuming "yes" to the above, I didn't realize an AutoOpen macro would run before the document is visible; perhaps there is a command one could insert that would "stall" the display of the MsgBox until the document is completely visible, but which would not delay the actual loading of the document. (Nothing comes to mind immediately that isn't ridiculous, like Find, using .Display for a short interval.)

    Or, it would be more work, but you could replace the MsgBox+InputBox with a UserForm opened with the "nonmodal" constant and see if the document continues to load behind the form. Or no, maybe that creates other problems...

  3. #3
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Opening Word from SQL (WinXP OXP)

    Jefferson thanks for replying

    Your assumption is correct all the code is embedded in the document.

    Couldn't find any code or suggestions on the net to delay the msgbox popping up. I am not sure I understand what the "nonmodal" constant is.

    cheers
    cheers

    Phil Carter

  4. #4
    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: Opening Word from SQL (WinXP OXP)

    I guess the first thing I get when I open a document containing an AutoOpen macro is the Enable/Disable dialog associated with "Medium" macro security. Are you bypassing this somehow? Anyway, the MsgBox pops up in front of the opened document after it is displayed, so I really am having trouble envisioning your scenario.
    Attached Files Attached Files

  5. #5
    4 Star Lounger
    Join Date
    Feb 2002
    Location
    Auckland, New Zealand
    Posts
    543
    Thanks
    56
    Thanked 0 Times in 0 Posts

    Re: Opening Word from SQL (WinXP OXP)

    If I open the document in Word directly I do get the Enable/Disable dialogue, but when the document is opened from our new database I do not. I do have other macros, on a separate toolbar, that only run on request when the document is open. These work just fine. Maybe I should just include a button on the toolbar allowing the user to change the address if they wish.

    I have made a request to our developers to see if they can answer my query. I will let you know if they reply.

    Cheers again
    cheers

    Phil Carter

  6. #6
    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: Opening Word from SQL (WinXP OXP)

    > when the document is opened from our new database

    Hmm... reminiscent of the way Auto macros are disabled when opened from a web page. If the database developers are using a "hyperlink" method to open the document, perhaps the same thing is happening. Interesting. I think the user intervention is a good idea. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

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