Solved

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

Posted on 1998-04-29
11
494 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
  • 7
  • 2
  • 2
11 Comments
 
LVL 2

Expert Comment

by:marti
Comment Utility
You may try dividing the document.
0
 

Author Comment

by:khbh
Comment Utility
Unfortunately it must be ONE document...
0
 
LVL 2

Expert Comment

by:marti
Comment Utility
I mean first printing say 50 pages and then the rest.
0
 

Author Comment

by:khbh
Comment Utility
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
Comment Utility
Edited text of question
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:khbh
Comment Utility
Adjusted points to 125
0
 

Author Comment

by:khbh
Comment Utility
Adjusted points to 200
0
 

Author Comment

by:khbh
Comment Utility
Adjusted points to 300
0
 
LVL 1

Expert Comment

by:lina10
Comment Utility
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
Comment Utility
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 300 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now