Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Traversing Characters with Code (Long Post!) (Word 97/2000)

    Topics have come up in the past where there was a need to create a macro that would traverse through a range of characters (all the characters in a cell, or a paragraph, or a document)

  2. #2
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Gary,

    The Characters (Items of the Characters collection) are Ranges, so they are objects.
    This isn't too much "overhead"; Ranges really consist only of two long pointers into the text, as far as I know. For a character, you really would need only one pointer (because the length is always two bytes); but since you can apply all methods that work with ranges directly to characters this way (otherwise you'd need to have a .Bold method for Ranges and another for Characters ...), this seems to be a reasonable simplification.

    Looping ForEach isn't much slower than your hand-crafted code. If you look closely, you'll see that nearly 99% of the time is spent with .Bold=True, not in the loop itself.

    The reason why
    <pre>For n = 1 To myRange.Characters.Count
    'Do something with 'myRange.Characters(n)
    Next n</pre>

    is so slow is that with indexed loops, Word starts to count from 1 to the index each time you use .Characters(n) in the loop, which results in a run-time that is proportional to n*n.

    For Each *

  3. #3
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Klaus,

    Thanks for responding to my (lengthy) post.

    Broadly, most of the elements in Word can be described as objects. What I was wondering about was the absence of a specific 'Character' class. (Your link to the thread last year reminded me that there is no 'Word' class either - Chris G. cites a specific mention of this from Word VBA help.)

    Somewhere in that thread last year, you posted some code along the lines of:

    For Each myWord in ActiveDocument.Words 'etc.

    - I think at the time you finessed it by not assigning a type to the 'myWord' variable <g>, but I gather it would be a range.
    And in fact, doing the same for Characters seems to work fine:

    Dim CharRng As Rng
    For Each CharRng in ActiveDocument.Range.Characters ' etc.

    As far as whether (or when) the 'For Each' works faster than the move range method I worked out, I don't really know how to accurately quantify that (by the way: would you care to share what test method you use to arrive at comparative elapsed times?).

    But as you note, I'm probably barking up the wrong tree about the speed of the loop method being the cause of the slowness in looping through a range of characters:

    If I loop through a range of characters, using any of the methods (index, ForEach, etc.) - but without having the code take any action in each loop, then the code executes essentially instantaneously no matter which method used.

    It's the addition of actual work, inside the loop, that causes things to slow down so drastically. The speed differences between the different loop methods, when they are 'loaded' with actual work such as setting a property, is beyond my crude testing means to measure, but in any case in the end it doesn't matter 'cause it's just going to be too darn slow to use no matter which way you do it! - at least that's the conclusion I have to draw. <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>
    Oh well, it was an interesting enquiry, anyway....

    Gary

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Gary,

    re timer/performance testing:
    You can put in "Dim Start: Start=Timer" at the beginning of a macro, and "MsgBox Timer-Start" at the end.

    re Dim myChar as Range:
    Yes, I define characters and words as Ranges; the added bonus is that Intellisense will help you if you do.

    I have learned quite a bit through discussions like this one, to optimize code... Often in such discussions others are convinced that all objects carry all the properties with them in one big package. But it's easy to convince yourself that characters couldn't be objects in this sense (imagine 1 MByte of characters, each with its own font, size, colour, spacing, ...). I'm convinced that with most objects in Word, quite a bit of code is involved in setting and retrieving properties (and that most of this code is slow, interpreted code that is poorly optimized because it doesn't pay off for Microsoft to spend a lot of money on it).

    So whenever possible, I try to manipulate larger chunks of text than characters or words. What I'm missing in Word is an easy way to work with ranges that have styles applied to them. It can be quite difficult to find the character style and paragraph style applied to some text, or to get the range of text that is formatted in some style.

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi again,

    Thanks for the Timer suggestion. I'd done something similar in the past by setting a variable = to Now, and then subtracting it from Now at the end (I think) but misplaced the code; anyway this is simpler.

    The syntax is new to me - you are declaring and assigning the variable in one statement. Worth mentioning that you can amend this to include a type assignment:

    Dim Start As Single: Start = Timer

    Now you've gotten me onto another mystery: when I test-run these macros, I get wildly different elapsed time results, from test-run to test-run. Actually, for each macro, I get two ranges of results - sort of a 'slow mode' and a 'fast mode'. So for instance, one of the macros will take 40-42 seconds to run some of the time, and 20-21 seconds to run other times (the relationship is not always 2:1) - there seems to be no pattern to when I will get a 'fast run' and when I'll get a 'slow run' (hardness of the ice, perhaps?<g>).

    Needless to say this frustrates attempts to quantify speed of execution (unless one notes the 'fast time range' and the 'slow time range' for each macro and does some calculus based on these).
    Any ideas as to what could cause such widely disparate results? I understand the PC has background processes going on but wouldn't expect it to change things that much (my home PC is a P2, 400Mhz, 128MB RAM, Word 2000 SR1, Windows 2000 Pro by the way). The only thing I've got running when I do these tests is Word (although of couse Win2K has got a few dozen processes going all the time).

    Do you tend to get similar disparities in speed? - in which case, I'd say there is something flaky here with the functioning of VBA. On other hand if you don't get these disparities, then there's something flaky about my PC (which I'll readily believe).

    With regard to characters as object, the article I provided a link to in the earlier post had very interesting information about how formatting is applied to characters in Word - to paraphrase: text is stored in the file as plain text, and formatting is stored in binary form "at the bottom of the disk image of the file with pointers into various offsets in the text". (I'd love to see more inside info like this about the workings of Word.)

    Anyway, that would explain (1) why characters themselves are lightweight and (2) why it's so difficult, as you note, to find character and para style info pertaining to specific text.
    Now, if you could get to Word's internal pointers for the formatting info, you might be able to do cool things, but how do you get to those? (There is commercial add-in app that does a kind of 'reveal codes' in Word - saw a demo but have forgotten the name - will track it down - how do you suppose that app (quickly) pulls together all that info?)

    As far as the slowness of VBA operations on properties, I don't know enough about what is going on under the hood to know whether that's due to poor optimization or just due to the limitations of VBA (safe bet that it is both).
    Since the bread and butter of what all of us are doing with VBA involves setting and retrieving properties, there's no way to get around the speed problem. VBA is a technical marvel (by the standards of a programming newbie like me), but it is going to be slow.

    Gary

  6. #6
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Gary,

    The ":" to separate instructions is a left-over from old Basic; I just used it so I didn't have to break the line <img src=/S/bagged.gif border=0 alt=bagged width=22 height=22>

    The speed differences you got are pretty common; I may well be wrong, but I think that Word uses a lot of internal caches to store information for later use, so a macro will very often run faster the second time around. I think even another macro may run faster if some information from a previous macro is still stowed away somewhere.

    To get reliable measurements, I prepare some test document and close it between runs. Though if you plan to run some macro repeatedly anyhow, I'd prefer one that uses the internal caches effectively <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    I don't know much of the memory (or file) format of a Word document, though it's surely something along the lines you describe. If you do a find/replace, say for "bold" formatting, Word has a rather easy time going through the document and locating the formatting, but if you parse a document on a character or word basis, it probably has to collect the information from the binary part (pointers) again and again, backtracking whether "bold" or "not bold" was most recently applied.

    Probably there isn't a way to drill down to the internal pointers. You could fudge something like your own markers embedded in the text:
    Since find/replace is rather fast, you can put in markers (tags) at the beginning/end of some formatting such as "bold" (Find what: -->bold, Replace with: X^&Y, where X and Y are some Unicode characters that don't appear elsewhere). Then you can use Range.MoveEndWhile CSet:="Y" ... to move to the end of the bold formatting, without having to check each character individually.

    But for those interested in a lot of (or all ) different formatting properties, it's probably easier in the long run to save as HTML and parse that.

    BTW, you really get a respect for the complexity of Word if you use the Watch window in the VBA editor and set a watch for one of the ranges in your macro <img src=/S/brainwash.gif border=0 alt=brainwash width=15 height=15>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Klaus,

    I'll have to try that Watch window, but in the meantime, here are some further observations that seem (to me anyway) quite interesting:

    1. It's (apparently) much faster to get a property than set a property (approximately 10x faster).
    2. It's faster still if you can cache properties in variables.

    1. Here is code similar to what I posted before, but this time changed so that we are getting properties rather than setting them - I'm storing the properties in an array and then printing the contents of the array out to the Immediate window. On my work PC, the previous code posted (which sets the font property to Bold), takes between 13-24 seconds.
    The following code takes 1.7 seconds to run:

    <pre>Public Sub GetCharPropsViaRange()
    'Gary Frieder February 2002
    Dim Start As Single: Start = Timer
    Dim CharRng As Range
    Dim CurParaChars As Characters
    Dim lngCurParaLen As Long
    Dim arIsCharBold() As Boolean
    Dim n As Long
    Dim i As Long
    Application.ScreenUpdating = False

    Set CurParaChars = ActiveDocument.Paragraphs(1).Range.Characters
    lngCurParaLen = CurParaChars.Count
    ReDim arIsCharBold(lngCurParaLen)

    Set CharRng = CurParaChars.First
    'Start array counter
    n = 0
    arIsCharBold(n) = CharRng.Bold
    n = n + 1
    Do While CharRng <> CurParaChars.Last
    CharRng.MoveStart 'Default is wdCharacter, 1
    CharRng.MoveEnd 'Default is wdCharacter, 1
    arIsCharBold(n) = CharRng.Bold
    n = n + 1
    Loop

    'Test to see if we have successfully stored values:
    For i = 1 To lngCurParaLen
    Debug.Print arIsCharBold(i)
    Next 'i

    Application.ScreenUpdating = True
    Set CurParaChars = Nothing
    Set CharRng = Nothing
    MsgBox Timer - Start
    End Sub
    </pre>

    - considering the extra work this version has to do, in storing to the array and then writing it to the Immediate window, it appears that getting a property is more than 10 times faster than setting one (at least in this case).

    2. Now take a look at the following code; this has been optimized further by creating a variable to store "CharRng.Bold" - so that you don't have to 'cross the dot' every time you iterate the loop - this code takes 0.9 seconds to run:

    <pre>Public Sub GetCharPropsViaRangeUsingVariablesToCachePropertie s()
    'Gary Frieder February 2002
    Dim Start As Single: Start = Timer
    Dim CharRng As Range
    Dim CurParaChars As Characters
    Dim lngCurParaLen As Long
    Dim CharRngBoldProp As Boolean
    Dim arIsCharBold() As Boolean
    Dim n As Long
    Dim i As Long
    Application.ScreenUpdating = False

    Set CurParaChars = ActiveDocument.Paragraphs(1).Range.Characters
    lngCurParaLen = CurParaChars.Count
    ReDim arIsCharBold(lngCurParaLen)

    Set CharRng = CurParaChars.First
    'Assign variable for Bold property:
    CharRngBoldProp = CharRng.Bold
    'Start array counter
    n = 0
    arIsCharBold(n) = CharRngBoldProp
    n = n + 1
    Do While CharRng <> CurParaChars.Last
    CharRng.MoveStart 'Default is wdCharacter, 1
    CharRng.MoveEnd 'Default is wdCharacter, 1
    arIsCharBold(n) = CharRngBoldProp
    n = n + 1
    Loop

    'Test to see if we have successfully stored values:
    For i = 1 To lngCurParaLen
    Debug.Print arIsCharBold(i)
    Next 'i

    Application.ScreenUpdating = True
    Set CurParaChars = Nothing
    Set CharRng = Nothing
    MsgBox Timer - Start
    End Sub
    </pre>

    Harkening back to the "Direct Formatting Detector" thread of several months ago - it might be worth revisiting the code I posted back then, using all of the above optimization methods - it would be interesting to see if the code then runs at an acceptable speed, or is still too darn slow (probably the latter! <img src=/S/laugh.gif border=0 alt=laugh width=15 height=15>)

    Anyway, the "cache frequently used properties as variables" (which idea I lifted from some MSDN documentation on optimizing code) is something to keep in mind and use when feasible - it can be used on either the left or right side of the assignment, depending on whether you are setting or getting.

    Regards,
    Gary

  8. #8
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Gary,

    Haven't time to check it right now, but are you sure your last macro works? It looks like
    <pre> arIsCharBold(n) = CharRngBoldProp</pre>

    will assign the same constant boolean value to all arIsCharBold(n) in the last loop <img src=/S/shrug.gif border=0 alt=shrug width=39 height=15>

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus

  9. #9
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi Klaus,

    I don't have time to check it either as it's been a very late night and I'm packing it in, but that possibly may be the case: I had test-run the code twice - once with all the characters in the document set to Bold, and once with all of them not set to Bold. So I got all Trues and all Falses.

    Guess I better test it on a document with mixed properties! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    I guess the question is: if the code were instead:

    arIsCharBold(n) = CharRng.Bold

    would that work to record differing values in each loop?

    And if Yes (which seems reasonable), then will "CharRngBoldProp", once it has been assigned as equal to "CharRng.Bold" (but outside the loop) not update its value every time the loop runs?

    Gary

  10. #10
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Hi again,

    Yes your instinct was right, and it doesn't work! <img src=/S/weep.gif border=0 alt=weep width=21 height=16>
    I'm still trying to figure out what that MSDN article was getting at, but I gather this technique is only useful if you are using a loop to assign a property (rather than get one). Then you could probably use something like:

    For Each aBmk in DocBookmarks
    aBmk.Range.Text = Text1Text 'stored as variable
    Next 'aBmk

    rather than

    For Each aBmk in DocBookmarks
    aBmk.Range.Text = Text1.Text 'specified object and property
    Next 'aBmk

    Not as supergroovy as I thought!
    Oh well, the first of the two macros in that post is still pretty darn fast...

    Gary

  11. #11
    5 Star Lounger
    Join Date
    May 2001
    Location
    Stuttgart, Baden-W, Germany
    Posts
    931
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Do you have the link to that MSDN article? Couldn't find it... and still hope there may be some way to get/set the properties of several characters in one go.

    Until I find some supergroovy new way, I keep using Find whenever possible. For example I just wrote the following two macros. Both check which characters in some document are bold and report their findings in the Direct window.
    The Find-macro was over 60 times faster on my test document!

    <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>Klaus
    <pre>Sub BoldTestChar()
    Dim myChar As Range
    Dim StartBold As Long
    Dim boolBold As Boolean
    Dim i As Long
    Dim Start As Single
    Start = Timer
    i = 0
    For Each myChar In ActiveDocument.Characters
    If boolBold = True Then
    If myChar.Bold = False Then
    Debug.Print " to " & i
    boolBold = False
    End If
    Else
    If myChar.Bold = False Then
    Else
    Debug.Print "(char) From " & i;
    boolBold = True
    End If
    End If
    i = i + 1
    Next myChar
    MsgBox Timer - Start
    End Sub</pre>

    <pre>Sub BoldTestFind()
    '
    Dim Start As Single
    Application.ScreenUpdating = False
    Start = Timer
    Selection.HomeKey Unit:=wdStory
    Selection.Find.ClearFormatting
    Selection.Find.Font.Bold = True
    With Selection.Find
    .text = ""
    .Replacement.text = "^&"
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = True
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    While Selection.Find.Execute
    Debug.Print "(find) From " & Selection.Start & " to " & Selection.End
    Wend
    Application.ScreenUpdating = True
    MsgBox Timer - Start
    End Sub</pre>


  12. #12
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Gary,

    I recall the thread from a few months ago (end of Nov/early Dec) on Direct Formatting Detector where you and Klaus went into a lot of investigation on this.

    I would not be surprised that getting properties is faster than storing properties. The latter involves a storage operation.

    >It's faster still if you can cache properties in variables
    what does it mean to "cache properties in variables"

    I would think the max speed that you could achieve in looping thru a bunch of chars would depend on what you're doing. From above, you'd never be able to achieve the speed you have with getting properties if, instead, you're trying to store properties. The issue is to loop thru the chars as quickly as possible and perform the operation as quickly as possible. On another thread dealing with Custom Document Properties on this board, StuartR observed, in response to my equiry, that testing (in a macro that updates fields in hdr/ftr) to see if a hdr/ftr's link-to-previous property was true was a very quick test but just doing a blind update on all hdr/ftr fields would slow things down tremendously.

    In the Direct Formatting Detector thread, I had asked whether:
    >Is there some way to gather info on the non-direct char formatting allowed for the document ahead of the char loop. That is, loop thru the para styles and the char styles and accumulate all non-direct formatting character attributes. Then in the char loop, compare each char to just 2 sets of char attributes:
    - the char attributes of the underlying para style for the para
    - the char attributes of each char style (of which I'm betting there won't be many)

    So, depending on what you're trying to achieve by looping, the suggestion might be worthwhile?

    Anyway, when all is said and done, I hope you'll summarize the final outcome for all of us mere mortals.

    Fred

  13. #13
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Klaus,

    When I test these two macros, the Find method is 6 times faster, not 60 - still that's a lot faster. <img src=/S/bravo.gif border=0 alt=bravo width=16 height=30>

    The MSDN article is part of the VB6 tutorial - I recently (belatedly) got hold of the MSDN disks so have this installed on my PC. They are probably online somewhere but I don't have the link. Anyway, here is the relevant section of the article - hopefully you can make more sense of it than I could!:

    Cache Frequently Used Properties in Variables
    You can get and set the value of variables faster than those of properties. If you are getting the value of a property frequently (such as in a loop), your code runs faster if you assign the property to a variable outside the loop and then use the variable instead of the property. Variables are generally 10 to 20 times faster than properties of the same type.

    Never get the value of any given property more than once in a procedure unless you know the value has changed. Instead, assign the value of the property to a variable and use the variable in all subsequent code. For example, code like this is very slow:

    <pre>For i = 0 To 10
    picIcon(i).Left = picPallete.Left
    Next I</pre>

    Rewritten, this code is much faster:

    <pre>picLeft = picPallete.Left
    For i = 0 To 10
    picIcon(i).Left = picLeft
    Next I</pre>

    Likewise, code like this . . .

    <pre>Do Until EOF(F)
    Line Input #F, nextLine
    Text1.Text = Text1.Text + nextLine
    Loop</pre>

    . . . is much slower than this:

    <pre>Do Until EOF(F)
    Line Input #F, nextLine
    bufferVar = bufferVar & nextLine & vbCrLf
    Loop
    Text1.Text = bufferVar</pre>

    However, this code does the equivalent job and is even faster:

    Text1.Text = Input(F, LOF(F))

    As you can see, there are several methods for accomplishing the same task; the best algorithm is also the best optimization.

    This same technique can be applied to return values from functions. Caching function return values avoids frequent calls to the run-time dynamic-link library (DLL), Msvbvm60.dll.

    Gary

  14. #14
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Fred,

    Re caching variables: see the snip from article in my response to Klaus.

    Re: Stuart's observation, I think the point there is that blindly updating all the fields in all the headers/footers can be very slow because there can be so many of them in a long document with many sections - if you were cycling through all the wdStoryRanges, I think it would have to make six updates per section (maybe more if my math isn't right).

    Re DirectFormattingDetector: I'll try to revisit that with your current comments in mind, now that I've learned a bit more (from Klaus<g>).

    As you can see from the fuzziness of the above comments, my inclusion in the mere mortal category is assured for some time to come! <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    Gary

  15. #15
    Silver Lounger
    Join Date
    Jan 2001
    Location
    West Long Branch, New Jersey, USA
    Posts
    1,921
    Thanks
    6
    Thanked 9 Times in 7 Posts

    Re: Traversing Characters with Code (Long Post!) (Word 97/2000)

    Gary,

    I think StuartR's observations are directly applicable here and, in fact, bear somewhat on the caching snippet.

    I'm not totally sure how the 6 updates per section is calculated. If this were "up to 6", I might guess it's based on a 1st page hdr, even hdr, odd hdr (similar for footer). Now suppose you only have 1 reg hdr/ftr per section (no 1st, even, odd) and that there's only 1 field in just the footer. But this ftr is linked to, say, 10 successive sections. I think what StuartR was saying was that it is much faster to check whether sec2's ftr is linked to sec1's ftr based on getting the property and skip the update if it is, rather than blindly update the field. I had naively asked why he performed the check given that the end results would be the same even if they were linked. It's just that you get to the end result faster if you don't blindly update the field. In this case, you really aren't caching anything. But you're just getting a property instead of updating something.

    As to the caching, I think it's clear to me why caching in variables is faster. Probably the VBE can access its variables "directly". Going for a property involves some dll. Running/calling another program like a dll probably has at least a little and probably a lot of overhead compared to just accessing a variable that the VBE has allocated space and can address. This almost gets to my suggestion about storing the formatting characteristics ahead of time. I would think that the same holds for even just accessing a field in a Word document. I'm guessing that anything the VBE does to access info from the document has to be slower than accessing a VBE variable. This seemed to be confirmed by Klaus's comment about where info is stored in the doc with the pointers, etc.

    I don't know if it's possible but if there are tools that allow one to see what processes are being executed between 2 breakpoints, it might be instructional to see what set of dll's get pulled in to access a property. Klaus mentioned how to set a timer for the time taken between the breakpoints. Again, I'd bet on the time for accessing a variable to be much shorter than going thru dll's.

    Hope some of this is of help.

    Welcome back to the mere mortal group. Somehow I didn't think of you down here with the rest of us.

    Fred

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •