Open cxw42 opened 5 years ago
Dictionary
should probably be Tim's Dictionary
class rather than Scripting.Dictionary
- merging this PR as-is would break Mac support AFAICT.
Ah! I see that his dictionary is a drop-in, so using it would give us the same name issue on Word.
What about conditional compilation? Word supports per-project variables, so this could work:
#If scripting = 1 Then
Dim d as Scripting.Dictionary
#Else
Dim d as Dictionary
#End If
(and similarly for New
calls). The README would then include the instructions for setting the variable if you're on Word.
The Dictionary class is referenced by name in only six places (and only two in the core), so I don't think this would be undue clutter. What say you?
The drop-in replacement needs to be unqualified since it lives in the same VBA project, and thus is resolved at priority 0 - qualifiers are redundant here, an unqualified Dictionary
will never be a Word.Dictionary
or Scripting.Dictionary
if there's a Dictionary
class in the VBA project; a fix would be to qualify the calls into the Word object model, which are resolved at priority 2, just after the VBA standard library, at priority 1.
I don't think there's an elegant solution for this problem, other than making the Word library calls explicitly qualified in the VBA project (i.e. not in vba-test code)... Or to use a unit testing framework that doesn't involve importing VBA code - like Rubberduck's (Windows only).
That said, I'm just a watcher here, Tim might have other ideas =)
@retailcoder Since the original changes were not workable, I have changed it to include the instructions for VBA-Dictionary in the README, and to include conditional compilation for those who want to use Scripting.Dictionary
.
I have tested 9ead5d4cb0900395eaf9f5d26e11d05c50861c57 on Windows Excel 2013 and Word 2013, both with Scripting.Dictionary
and with VBA-Dictionary. I don't have access to a Mac, so unfortunately can't test there.
(For what it's worth, I'd like to get Word support into master because my next trick is a multi-file test runner for Word VBA :) .)
Thanks for creating this project! I am using it on Word VBA. However, on Word,
Dictionary
is ambiguous, since it could beWord.Dictionary
orScripting.Dictionary
. This PR specifiesScripting
to avoid compilation failures.All tests pass on both Excel 2013 and Word 2013.
Thanks for considering this PR!