Solved

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

Posted on 1998-04-29
11
499 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
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
 

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
Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

 

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 300 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In Debugging – Part 1, you learned the basics of the debugging process. You learned how to avoid bugs, as well as how to utilize the Immediate window in the debugging process. This article takes things to the next level by showing you how you can us…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

932 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