Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
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 September 28th, 2010, 11:36 AM
Authorized User
 
Join Date: Oct 2003
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Exclamation Word doc becomes inactive when moving to a sub

This is an update of my previous post.

We are merging data with a Word doc. Depending on certain conditions, we insert a second doc and merge data to the second doc.

The merge for the second doc is done in a Sub and we have been using the following code in the Sub to do this.

Code:
Set objWord = GetObject(, "Word.Application")
Set oDoc = objWord.ActiveDocument
The error occurrs at this point and states that "The command is not available because no document is open".
Code:
Do While TheEnd = False
    If rstC!AffNeeded1 = True Then
        objWord.ActiveDocument.Bookmarks("BottomBook").Select
        objWord.Selection.InsertBreak Type:=wdSectionBreakNextPage
        objWord.Selection.InsertFile FileName:= <FileName>
It works fine until the Sub is called.

A little history: This report has been run, almost daily, for about 4 years. The code has not been changed. The failures started happening around the 14th of this month.

Anyone have any thoughts?

Thanks

Ray





Similar Threads
Thread Thread Starter Forum Replies Last Post
printing a word doc from badgolfer ASP.NET 1.0 and 1.1 Basics 2 December 13th, 2013 07:06 AM
Creating word doc - word behaviour mat41 Classic ASP Professional 2 April 29th, 2007 06:46 PM
Copy text from 1 doc to other doc thru vba in word itchock Word VBA 2 December 29th, 2006 02:47 AM
Word Doc from Database NinaWilliam ASP.NET 1.0 and 1.1 Basics 2 August 22nd, 2006 11:41 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.