Property Let Procedure Error 
Author Message
 Property Let Procedure Error

I have a macro with the following line of code:
ActiveDocument.Content.InsertBefore vWordPick
(vCounter).Formatted Text
and the error I get is:
Property let procedure not defined and property get
procedure did not return an object.

This macro worked fine until I added a few lines of code
where the macro opens up a new, blank document and
switches between two documents.  I read the explanation
for the error message which said that this object was not
part of a collection but isn't "ActiveDocument"
automatically part of the documents collection?



Wed, 29 Jun 2005 02:01:55 GMT  
 Property Let Procedure Error
Hi Joanne

I suspect that "Formatted Text" should be one word "FormattedText"

--
Regards
Jonathan West - Word MVP
MultiLinker - Automated generation of hyperlinks in Word
Conversion to PDF & HTML
http://www.multilinker.com
Word FAQs at http://www.multilinker.com/wordfaq
Please post any follow-up in the newsgroup. I do not reply to Word questions
by email


Quote:
> I have a macro with the following line of code:
> ActiveDocument.Content.InsertBefore vWordPick
> (vCounter).Formatted Text
> and the error I get is:
> Property let procedure not defined and property get
> procedure did not return an object.

> This macro worked fine until I added a few lines of code
> where the macro opens up a new, blank document and
> switches between two documents.  I read the explanation
> for the error message which said that this object was not
> part of a collection but isn't "ActiveDocument"
> automatically part of the documents collection?



Wed, 29 Jun 2005 03:35:38 GMT  
 Property Let Procedure Error
Joanne

Yes, the ActiveDocuement is always active.  It really doesn't belong
to a collection.  It is really a pointer and it points to the document
which is the active document as far as the user is concerned.

If there are no documents open then the value of the ActiveDocument
pointer is Nothing.

The problem, I'll wager, is that the ActiveDocument pointer is
pointing to the new document which you have created.   The thing to
do, if this is the case, is to try to keep track of the documents and
to make sure that you are working on the correct document.

I would do this by creating two new pointer variables:

  Dim oOldDoc as Document
  Dim oNewDoc as Document

having done that then make a note of which document is the 'original'
active document by, before creating the new document, this line of
code:

  Set oOldDoc = ActiveDocument

Of course, you may need to put checks in here that there is an
ActiveDocument; but I dare say that these are already in your code.

Then you create, open or whatever your new document.  This means that
the ActiveDocument pointer is now pointing at the new document and not
the one which you were originally working on:

 ' Creating/opening a new document here..   Then do the following:
  Set oNewDoc = ActiveDocument

Now, you have two pointer variables; oOldDoc and oNewDoc.   These now
point to the correct documents in how you will want them to do.

Then instead of referring to the document with code such as:

 ActiveDocument.Content.InsertBefore ...

You can use the following:

oOldDoc.Content.InsertBefore  ...     or
oNewDoc.Content.InsertBefore

and then you would be sure that you will be working on the correct
document and then these problems which you describe will vanish.

I am planning to write a series of articles on pointers in VBA on my
Web site.  Mostly because most people haven't been told about them and
then they pick up some ideas about these variables but don't have
enough information to use them properly.  Also having been told by a
MVP here that I don't understand them myself (ha!) I aim to put the
record straight and to help others with problems such as this.

Anyway, I hope that this helps.  If it doesn't then please do get back
to me here on the forum.

Regards
  Malc
  www.dragondrop.com



Fri, 01 Jul 2005 17:21:22 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Error 451: let property not defined

2. property get / property let

3. Property Let, Property Get

4. Property Let vs. Property Set

5. Property Procedure and Error 438

6. udt's as parameters to Form Let Property procedures - Errors???

7. property let and get,

8. Property Get, Set Let with Classes

9. Property Let problem

10. Using arrays as arguments in Let and Get Properties

11. Class Property Get Let

12. Property Let/Get and passing arrays

 

 
Powered by phpBB® Forum Software