Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-04-29
11
Medium Priority
?
527 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
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.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
Explore the ways to Unlock VBA Project Password Excel 2010 & 2013 documents. Go through the article and perform the steps carefully to remove VBA Excel .xls file.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

782 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