Solved

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

Posted on 1998-04-29
11
517 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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