• WSrhadin

    WSrhadin

    @wsrhadin

    Viewing 15 replies - 76 through 90 (of 102 total)
    Author
    Replies
    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #995120

      Thank you, again, Richard. I haven’t had a chance to try the revised code or even to work with it — I’m sorry to say that earning my paycheck is distracting me from what I’d rather be doing, which is working on the macros. I probably won’t be able to get back to the macros until the weekend. Yes, this will be an auxiliary macro until I can merge the files.

      I would, however, like an answer to my original question — a “yes” or “no” will do: Can an interface like I originally asked about be done? I would like to know just to satisfy my curiosity. I am grateful for all the help I have been given and the solutions suggested are the ones I will implement (with some tinkering), but no one has said “Yes, the interface can be done but . . .” or “No, VBA won’t let you create such a solution because . . .” or whatever the appropriate answer is. Thanks.

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #995051

      Thanks, Richard, for the suggestion and the starting code. I have a couple of questions (which will reveal how little I understand VBA smile ).

      1. Why is the underscore needed in the Key as in due_to?
      2. Is there a limit to the size of an .ini file (except for it becoming too cumbersome), or is it just like a .txt file? By size limit, I mean a maximum number of entries (e.g., a custom dictionary is limited to 5,000 entries).
      3. I note that there is no space on either side of the =. Is this required or can there be a space?

      I tried your code as is but am unable to get it to work properly. It does delete the existing word, but does not replace it with the new word — it simply leaves the space empty. Something for me to check into.

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #994946

      Thanks, Hans.

      I will use this code as a starting point. I tried it and it works as you said. I appreciate the help. This will give something to do over the next few weeks.

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #994893

      Thanks for the suggestion, but it does not apply to these particular macros — at least I don’t think it does. There seems to be a continuing misunderstanding about the macros for which I want the interface: they are not search (or find and replace) macros. The macros are used as the editor reads the manuscript and are designed to facilitate making editing changes based on context, by which I mean that the editor has to consider context and style in deciding whether a particular term is properly used.

      Consider as an example the words “since” and “because”. You cannot do a find and replace to change every instance of “since” to “because” because the determination of which is correct depends on its use in context. They both have a causal sense, so in common English they are used interchangeably to convey a causal connection (“since the virus produces symptoms”, “because the virus produces symptoms”), but grammatically there is a distinction and “since” is used to convey a sense of time (“since he turned 18 he has lived alone”) and “because” to convey a causal connection (“because he turned 18 he could legally drink alcohol”). Consider the difference in meaning that occurs when replacing “since” with “because” in this example: “because he turned 18 he has lived alone”. Which does the author mean: the cause of his living alone was that he turned 18 or he has lived alone from the time he turned?

      My point is that the toggle macros serve a different purpose than a search macro and cannot (should not) be used in the same manner. It has been suggested that a find and replace macro that asks each time whether to make a change would work, and it will for some things, but not for what the toggle macros are intended to do. Additionally, if you had to run through a list of 50 terms in a 125-page document answering yes or no regarding replacement, the edting time would increase dramatically and the number of errors introduced would increase.

      OTOH, if there is a way to adapt the suggestion of having the terms in a .txt file rather than as part of the VBA macro yet essentially work the same (i.e., as a toggle rather than as a search and replace), I am open to that; in fact, I think that would probably work better, especially because words and phrases could easily be added to a .txt file. But I admit that I don’t know how to write the toggle macro so that the user could place her cursor in a word or could select a phrase and have the macro compare the word/selection against the contents of the .txt file and if found, replace the word/selection with an alternative. This warrants further investigation.

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #994774

      The more I think about your two macros, NeuroDoc, the more intrigued I am. I think your suggestion would be useful, but for a different task than the toggle macros. I know that it seems as if a F&R macro should work, but it doesn’t — we have tried that in the past, although not with option to change or not change.

      Would you be willing to share with me the code you use for both the macro and the add-to-list dialog box? When a word is added to the list via your dialog box, will the word/phrase be included in the search the next time the macro is run or do you have to exit and restart Word? Can your macro deal with punctuation? For example, could I enter J. Cardiovasc. Surg. as the find phrase or microbally-derived or are there limitations as to how the find phrase is constructed? Is it case sensitive? Is there a limit as to the number of words or phrases that can be in the Find list?

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #994724

      Thanks for the suggestion, NeuroDoc, but the macro you suggest is essentially a find and replace macro. The macro would work great if we were correcting misspellings or something that doesn’t require making a decision based on context. The toggle macros are based on grammar decisions made in context. For example, if it were always incorrect to use “principal” because in every instance “principle” was meant, the macro you suggest would work fine. But consider this:

      “The principal’s principles were immoral and the assistant principal did nothing to correct those principles.”

      Any change has to be decided in context — the context not only of the current sentence, but of the preceding and succeeding sentence.

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #994723

      Hans, autotext doesn’t accomplish the same thing with the ease of the macro. In addition there are usability limitations. Consider the following. In the sample code I provided, if the editor comes to a sentence that reads, for example,

      “the distance between the patient’s eyes was 2.5 centimeters”

      to change “centimeters” to “cm”, the editor simply puts her cursor somewhere in the word “centimeters” and presses the activation key (which is a single key) . With AutoText, the editor has to (a) select the word to be replaced, ( open the AutoText menu, © find the correct main menu, (d) find the correct submenu, perhaps having to go through several, and (e) select the correct replacement and click it. As the number of entries increases, the time it takes to find the replacement text increases.

      Also, consider the variations. Some combinations require multiple variations. For example, the “which” and “that” combination has 4 possibilities: that > which; which > that; That > Which; and Which > That. The “principal” and “principle” combination has 8 possibilities principal > principle; Principal > Principle; principals > principles; Principals > Principles; principle > principal; Principle > Principal; principles > principals; and Principles > Principals. As you can see, the list can grow. Consequently, it is much quicker to press a single key than to use AutoText.

    • in reply to: Interface to a Word VBA macro (Word 2003 SP2) #994643

      I am not concerned about the “aberrations” such as the superscripting because that occurs infrequently. If an interface can be done that would just handle the straight text, that would be perfect. The usual entries have no superscripting or subscripting, which would be the only variations from straight text in any case. What I really want is for the enduser to have a box that says, e.g.,

      Change [word] of [number] characters
      To [word]

      Add to: [checkbox] General Words
      [checkbox] Medical Acronyms
      [checkbox] [other macro choices]

      Add Cancel

      and then have automatically added to the checked macro and in the correct place the following code with the information filled in:

      ElseIf target = “[change word]” Then
      ActiveDocument.Range(Start:=aaa, End:=aaa + [number of characters]).Delete
      Selection.TypeText Text:=”[to word]”

      Of ocurse, it would be even better if the enduser didn’t have to provide the character count, that the macro could provide it automatically.

      Is this interface possible?

    • in reply to: Clearing a Variable When File Closed (Word 2003) #989987

      Thank you, Jan. I appreciate the code that I can use as a guide. It is clear that I have a very long way to go for even a semblance of mastering VBA.

    • in reply to: Clearing a Variable When File Closed (Word 2003) #989985

      Thanks, Stuart. I will search the WithEvents as you suggest. I haven’t yet used application events, so it will be a new adventure for me.

    • in reply to: Browsing and Multiple File F&R (Word 2003) #989663

      Thank you, Hans. I just looked at post 538,061 and see that it uses the FolderPicker. I had tried to write my macro using FolderPicker, but I had been unable to figure out how to get it to retain the selected folder name. I see that my error was in the If . . . End If statement. I appreciate your leading me to this code.

      I also thank you for the InputBox code. Again I had tried using the InputBox but I had it completely backwards, which is why I couldn’t get it to work and why I assumed I was trodding down the wrong path.

      As for the third item, that I had no clue about, so thank you a third time.

      I much appreciate the help you have been giving me. I do learn each time and I always try to solve the problem before I ask for help on the forum. I hope someday to be able to return the favors by being in a position to offer help to others.

    • in reply to: Simulating Mouse Action in VBA (Word 2003) #989117

      Perfectly, Hans. Again, I thank you.

    • in reply to: Simulating Mouse Action in VBA (Word 2003) #989113

      Thanks, Jeremy, but I can’t duplicate the task that way.

    • in reply to: Simulating Mouse Action in VBA (Word 2003) #989111

      Hans,

      I know it doesn’t seem to make sense but in fact it does accomplish something.

      In an earlier request for help, you provided VBA code that would reload a custom dictionary after adding a word to it so that the word would no longer be considered misspelled. Although the dictionary reloads, the red squiggles indicating that the word is misspelled do not disappear unless I right-click on the word. This is what I am trying to accomplish — simulating my right-clicking on the word.

      I tried to approach it by writing code to select IgnoreAll before selecting the word for inclusion in the custom dictionary, but I was unable to figure out code that would accomplish that task.

    • in reply to: Word Macro to Highlight Text (Word 2003 SP2) #987249

      Thank you, Hans.

      The code you provided works (I only had to change the ? in the two Select Case MsgBox statements to _). After reading it, I can tell you that I was so far off in my coding that I shouldn’t even call what I had done coding. sigh With this core code, I think I can finish writing the code for the macro — I will give it a try. I appreciate the help and the quick response. thankyou

      Rich

    Viewing 15 replies - 76 through 90 (of 102 total)