?
Solved

Problems creating a Word.Basic object, when Word is loaded

Posted on 1998-04-29
11
Medium Priority
?
525 Views
Last Modified: 2008-02-01
Hi!
I've made an Access 2.0 application that generates a Word document. In Access 2.0 it didn't matter whether Word was loaded or not, but in Access97 it does. I have this code:

Dim WordObj As Object
Set WordObj = CreateObject("Word.Basic")

When generating the Word document (up to 100 pages), in Access97, I get a message after a while that the object is too complex and that I should make a full save. This wasn't a problem in Access 2.0.
What should I do?
Putting in statements as "WordObj.FileSave" isn't a good solution as it is very time consuming and it isn't suitable in my application.

Another problem with Word.Basic-objects is that I can't make Word97 jump to a bookmark the way I could in Word6.0.
With other words, the statement "WordObj.EditGoTo 'Final'" doesn't work the way it used to. In this case the bookmark 'Final' resides about 5 pages earlier than the current page the cursor is on, and the statement above just moves the cursor to the top of the current page, not to the bookmark 5 pages back.

/Henrik
0
Comment
Question by:khbh
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
  • 2
11 Comments
 
LVL 2

Expert Comment

by:marti
ID: 1957602
You may try dividing the document.
0
 

Author Comment

by:khbh
ID: 1957603
Unfortunately it must be ONE document...
0
 
LVL 2

Expert Comment

by:marti
ID: 1957604
I mean first printing say 50 pages and then the rest.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:khbh
ID: 1957605
It must be saved in ONE document before printing it.

Another thing, there is no easy way of telling how often to put in statements like "WordObj.FileSave" to correct the problem, and to be sure that the error doesn't occur the statements must occur too often in the code, leading to time consuming actions.
0
 

Author Comment

by:khbh
ID: 1957606
Edited text of question
0
 

Author Comment

by:khbh
ID: 1957607
Adjusted points to 125
0
 

Author Comment

by:khbh
ID: 1957608
Adjusted points to 200
0
 

Author Comment

by:khbh
ID: 1957609
Adjusted points to 300
0
 
LVL 1

Expert Comment

by:lina10
ID: 1957610
Hello!
1. have you noticed that the syntax varies in some statements
   in word95 version and a word6.0 version? word97       understands the   word95 basic version.

2. if you are using a word97, why not refference a word8.0 object library instead of word.basic?
0
 

Author Comment

by:khbh
ID: 1957611
Hi lina10!
1. I don't think that the syntax is the problem here, because I can compile the module.

2. How would I do that? What would the corresponding code for "WordObj.EditGoTo 'Final'" look like with a Word8.0 object. 'Final' is a bookmark in the document that I'm working on in Word.
0
 
LVL 1

Accepted Solution

by:
lina10 earned 1200 total points
ID: 1957612
Hello!
for the word8- create a refference to the word8 object library in your app
in a module, declare a global object(in this case, it is newApp)
  in the event:
  (please note that i had to write dim newApp as object in the event, just to be able to get objects in the word8 library, then i comment this line before the execution)

Set newApp = GetObject(, "Word.Application")
    newApp.Visible = True
  newApp.Documents.Add "C:\Program Files\Microsoft_    Office\Templates\test1.dot", False
  newApp.ActiveDocument.SaveAs "test4.doc", wdFormatDocument, False, "", True, "", False, False, False, _False, False
  newApp.Selection.GoTo wdGoToBookmark, , , "final"
  newApp.Activate
  newApp.WindowState = wdWindowStateMaximize
  Set newApp = Nothing

Of course, there is a lot of experimenting to do. I find it very helpful to record a macro in word8 and look at the syntax to understand the actions better. following is the macro i recorded for this case:
'Documents.Add Template:= _
 ' "C:\Program Files\Microsoft Office\Templates\test1.dot",_  '   NewTemplate:= False
 '   Application.KeyboardLatin
 '   Application.KeyboardBidi
 '   ActiveDocument.SaveAs FileName:="test1.doc", FileFormat:=wdFormatDocument, _
 '        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
 '       :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
 '       SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
 '       False
 '   Selection.GoTo What:=wdGoToBookmark, Name:="final"
 '   With ActiveDocument.Bookmarks
 '       .DefaultSorting = wdSortByName
 '       .ShowHidden = False
 '   End With
0

Featured Post

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question