Solved

Storage and EnumElements order...

Posted on 2002-06-21
15
283 Views
Last Modified: 2012-06-27
Hi !

How can I change the order of the recursivity of the EnumElements ?

I have a .DOC file with the following structure:

   WordDocument
   Macros
      VBA
         Appder
         AutoClose
         ThisDocument

But... the real order is:

   WordDocument
   Macros
      VBA
         AutoClose               <-  The correct position
         Appder                  <-  The correct position
         ThisDocument

I need a sample C/C++ source code for correct this order... I need only display in the correct order...

Thank you
0
Comment
Question by:masvmasv
[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
  • 6
  • 4
  • 2
  • +3
15 Comments
 
LVL 30

Expert Comment

by:Axter
ID: 7098479
What do you mean by the real order?

Your question is abiguous.  Please explain.
0
 

Author Comment

by:masvmasv
ID: 7098563
The order of the object is load if I open the file in the word..
Inside the MACRO/VBA... have the macro source code...
In the first time, the Word execute the macro inside
AutoClose... after this... execute the Appder and after the "ThisDocument" macro...
the correct order is:

AutoClose, AppDer, ThisDocument

But, if I enumerate the itens inside the .DOC file, the display order is:

Appder, AutoClose and ThisDocument...

How can I change the enumeration order ?

Thanks
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 100 total points
ID: 7099602
It looks like it is displaying them in alphabetical order.  I suggest that you just write a new macro that calls each of these macros in the desired order.

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

 
LVL 22

Expert Comment

by:ambience
ID: 7102739
masvmasv the order in which Word executes macros does not depend upon the order in which they persist in the storage.

ofcourse Open fires first and then Close even though that is not in alphabetical order or storage order, but the order mandated by Word object behaviour model (hope i've got it right this time).

so if you want to show them in the right order you have to do that yourself, consult MSWord help on macros and that should give you a list of all the macros and the sequence they follow.

You only have to check for the macros in that sequence and if you find one you display it or do whatever with it.
0
 

Author Comment

by:masvmasv
ID: 7103840
Hi... thanks...

But... in the MSDN... have this article at:
"Storage::EnumElements":

"The order in which the elements are enumerated and whether the enumerator is a snapshot or always reflects the current state of the storage object, and depends on the IStorage implementation"

Another solution for the problem ?
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7104867
>>and depends on the IStorage implementation"

That indicates to me that if Word wants to implement IStorage in alphabetical order or ordered by date of creation or or ordeded randomly, it can.

You will need to examine each item enumerated.  Perhaps there is a datestamp or a key field that will tell you the order in which the macros are executed.  You might just need to learn this by trial and error (make a bunch of documents with a bunch of macros in various order and see what happens when Word closes).

Eamine the STATG for each item.  There is a timestamp and other data there.  You should be able to see a pattern.

-- Dan
0
 
LVL 22

Expert Comment

by:ambience
ID: 7106738
>>depends on the IStorage implementation

am sorry to say that does not bear any restriction on the order in which an application should use the elements. Why would there be a need for word to have macros saved in a specific order. In Word a macro is always executed upon some event (that can also be the user selecting to invoke a macro), some of which are predefined like Close is fired when a document is about to close etc.

Why would then the macros be sorted based on something, if there is no macro for Close it wont be fired and thats it. If you add a new macro or remove an existing macro do you think word would re-order the remaining macros and write them in some order again ?

I hope you've got my point.
 
>> key field that will tell you the order in which the macros are executed

if there is any such field , then that is information for me.

somebody correct me if i am wrong.
0
 

Author Comment

by:masvmasv
ID: 7120039
Hi !

I´m testing the STATG structure, and I convert the .atime, .mtime and .ctime elements, and always returned 00:00:00 ... :-(

But I extract the macro source code with the HMVS utility, adn the order it´s correct... and I test with LIBOLE2 (a LIB made for OLE2 compatibility with Linux)... and the order is the same than HMVS... but the order is not correct with the EnumElements... :-(

I dont have another way... the LIBOLE2 is very confusion and I dont know another LIB source code with OLE2 compatibility...

If you know another, please... send to me...

Thank you

0
 

Author Comment

by:masvmasv
ID: 7120045
But...

The LIBOLE2 is not only consufion... but it´s limited, because dont allow delete storages or streams and have many bugs too...

Thank you
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7120769
What is the HMVS utility?
-- Dan
0
 

Author Comment

by:masvmasv
ID: 7120792
Hi!

The HMVS utility is used for retrieve a macro source code inside OLE2 files... but they is used for detect/remove macro viruses...

do you can download it from here:
http://www.simtel.net/pub/pd/6638.html

Thank you
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7120793
Try adding several other macros (like Appder1 and ZappDer) and you will find that they are enumerated in the desired order.

AutoClose and ThisDocument are special cases.  You need to provide special-case handling for them.  That is, there is nothing about the enumerated order that forces Microsft Word to execute them in that order.  For instance, if the user starts Word with /m or while the SHIFT key is pressed, automatic macro processing is not performed at all.

So you are asking the wrong question.  Your question needs to be:

In what order does MsWord execute these macros?

   ... and the answer IS! ...

Whatever order it deems best.  It executes special macros such as AutoExecute and AutoClose in an otrder that depends upon its own unpublished internal rules.  Other macros seem to be executed in alphabetical order.

If your question is:
How do I control the order in which MsWord excutes macros, then the answer is easy (and I gave it to you some time ago) Write a macto that executes the other macros in the desired order.

Do you have a different question to ask?  If so, try to decide exactly what you need to know.  THink it over and  type that new question carefully.  If you add some explination as to why you need to know it, it will help us to help you.

-- Dan
0
 

Author Comment

by:masvmasv
ID: 7122766
Hi !

Sorry for my bad english...
I thing my english dont help me :-)

Where can I found a complete list with the AUTO* macro names ?

Maybe, if a make a quicksort routine for sort AUTOMacros and after this, sort the anothers macros, I can make the same order than HMVS...

Thanks
0
 
LVL 11

Expert Comment

by:griessh
ID: 7284936
Dear

I think you forgot this question. I will ask Community Support to close it unless you finalize it within 7 days. You can always request to keep this question open. But remember, experts can only help you if you provide feedback to their questions.
Unless there is objection or further activity,  I will suggest to split between

     "DanRollins & ambience"

comment(s) as an answer.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
======
Werner
0
 
LVL 6

Expert Comment

by:Mindphaser
ID: 7332973
Force accepted

** Mindphaser - Community Support Moderator **

ambience, there will be a separate question with points for your help.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

617 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