Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 10th, 2003, 06:53 PM
Registered User
 
Join Date: Oct 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Working with Word

I've finally sorted out linking to a word document and completing sections using bookmarks:

        Set objWord = CreateObject("Word.Application")
        With objWord
        .Visible = True
        .WindowState = wdWindowStateMaximize
        .Documents.add ("c:\abc\formletters\planapply.doc")
      .ActiveDocument.Bookmarks("one").Select
etc etc

But.. I want to halt code at this stage until I exit word with the windows window still visible - hopefully a simple solution available but what is it please? I guess I'm looking for some sort of On Exit routine based on the word object

 
Old October 10th, 2003, 11:04 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Humor me here. First, I'm not sure what the "windows window" is so you'll have to grant me a little latitude. I'm not quite sure what you are trying to do.

Usually, when I exit Word after an automation session, I simply return to Access, though by this point the procedure that instantiaited Word has completed, and my Word application variable is out of scope, destroyed. However, VBA is unavoidably single-threaded, so you can always halt code execution indefinitely by simply displaying some type of message box. As long as the message box is displayed, nothing else on the Access side can occur, absolutely nothing.

Your word app appears at the line:

.Visible=True

So immediately following:

.ActiveDocument.Bookmarks("one").Select

You could insert some code like:

Dim strMessageTitle As String
Dim strMessage As String
Dim intReturn As Integer
strMessageTitle = "Resume processing?"
strMessage = "Would you like to continue processing?"
intreturn = MsgBox(strMessage, vbYesNoCancel + _
  vbQuestion + vbDefaultButton1, strMessageTitle)

Your Access VBA code will halt here. This message box won't appear over your word document. It will only exist in the Access process and won't effect the process Word is running in at all. When you close Word, you'll be back at Access, greeted by the message box asking you if you want to resume the execution of the code in your Access module. Its actually pretty unobtrusive.

Anyway, just a possible work-around that occurred to me.

HTH,

Bob






Similar Threads
Thread Thread Starter Forum Replies Last Post
Working With Word Template From ASP.NET and VB.NE Haribabu74 Classic ASP Components 2 July 22nd, 2014 05:11 PM
Creating word doc - word behaviour mat41 Classic ASP Professional 2 April 29th, 2007 06:46 PM
Word automation is not working in terminal server kalees ASP.NET 1.0 and 1.1 Professional 0 September 20th, 2006 04:03 AM
Working with Word pannet1 BOOK: Expert One-on-One Access Application Development 2 September 12th, 2004 01:04 PM
Copy word to word doc. in VB vamshi Pro VB 6 1 March 24th, 2004 06:25 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.