MS Word Macro question;

Page 1 of 1 (11 items)
This post has 10 Replies | 1 Follower

Posts 151
Dave L | Forum Activity | Posted: Tue, Sep 15 2015 1:14 PM

I need to convert Scripture references from abbreviated form to whole word form. For instants, Rom. to Romans. Not just for a single book of the Bible but for all. Do I need a separate macro for each book or can I write a single macro with every book listed and change any or all at once?

Posts 3809
spitzerpl | Forum Activity | Replied: Tue, Sep 15 2015 4:59 PM

you could certainly create a macro to change them all at once. Or you could create a user form that would allow you to put a check mark next to the books you want to change. I would open the book as a PB in logos, then print it back to word as a word doc. That way you could write the macro to only change things it finds inside hyperlinks to avoid changing things you may not have intended to change.

Posts 151
Dave L | Forum Activity | Replied: Tue, Sep 15 2015 5:09 PM

Thanks for the prompt answer. I'm not too familiar with the "user form" but I'll look into it. Sounds promising.

Posts 3661
BillS | Forum Activity | Replied: Wed, Sep 16 2015 10:32 AM

You might try using wildcards. To convert every instance of the string in quotes "Gen. [any number 0-9]" to Gen. [same number], with MS-Word Wildcards, you could Replace All instances of Gen. with Genesis with the following:

It'd be pretty easy to record a macro with one of these & then edit /expand it afterward to include all of your most common abbreviations for all 66 books. It'll find any instance of your abbreviation in the context of a chapter number.

The text part of the search argument has to be exact (capitalization, etc.).

Blessings!

Grace & Peace,
Bill


Asus GF63 8RD, I-7 8850H, 32GB RAM, 1TB SSD, 2TB HDD, NVIDIA GTX 1050Max
Samsung S9+, 64GB
Fire 10HD 64GB 7th Gen

Posts 3661
BillS | Forum Activity | Replied: Wed, Sep 16 2015 10:36 AM

spitzerpl:

you could certainly create a macro to change them all at once. Or you could create a user form that would allow you to put a check mark next to the books you want to change. I would open the book as a PB in logos, then print it back to word as a word doc. That way you could write the macro to only change things it finds inside hyperlinks to avoid changing things you may not have intended to change.

Help me understand a user form.... that sounds interesting. Could you give us detail with pix on how to do that?

Grace & Peace,
Bill


Asus GF63 8RD, I-7 8850H, 32GB RAM, 1TB SSD, 2TB HDD, NVIDIA GTX 1050Max
Samsung S9+, 64GB
Fire 10HD 64GB 7th Gen

Posts 151
Dave L | Forum Activity | Replied: Wed, Sep 16 2015 11:06 AM

Thanks Bill! this looks like something I can handle that will work well.Yes

Posts 3809
spitzerpl | Forum Activity | Replied: Thu, Sep 17 2015 7:12 PM

Sure. Within VBA I set up the attached userform. and put the following code behind it. If you select select all, it changes all, old testament changes all OTs, New Testament all NTs. I don't have the time to actually set up the replacing of text but this is a sample. If you need more step-by-step on how to do this I might be able to give it to you. I can probably also send you the userform I put together. My VBA knowledge is mostly self-taught so there's probably a better way to go about this.

Option Explicit

Private Sub CancelButton_Click()
Unload Me
End Sub

Private Sub NTSelect_Click()
Dim ct As Control
Select Case NTSelect
    Case True
        For Each ct In PassageSelect.NTFrame.Controls
            ct = True
        Next
    Case False
        For Each ct In PassageSelect.NTFrame.Controls
            ct = False
        Next
End Select
End Sub
Private Sub OTSelect_Click()
Dim ct As Control
Select Case OTSelect
    Case True
        For Each ct In PassageSelect.OTFrame.Controls
            ct = True
        Next
    Case False
        For Each ct In PassageSelect.OTFrame.Controls
            ct = False
        Next
End Select
End Sub


Private Sub SelectAll_Click()
Dim ct As Control

Select Case SelectAll
    Case True
        For Each ct In PassageSelect.OTFrame.Controls
            ct = True
        Next
        For Each ct In PassageSelect.NTFrame.Controls
            ct = True
        Next
    Case False
        For Each ct In PassageSelect.OTFrame.Controls
            ct = False
        Next
        For Each ct In PassageSelect.NTFrame.Controls
            ct = False
        Next
End Select
End Sub

Posts 151
Dave L | Forum Activity | Replied: Fri, Sep 18 2015 3:38 AM

Thank you spitzerpl.  This is a perfect solution. I need to learn about how to do this but it justifies the time spent.

Thanks!

Posts 3661
BillS | Forum Activity | Replied: Fri, Sep 18 2015 11:55 AM

Hi spitzerpl,

Thanks for modeling what you were talking about... Blessings to you!

Grace & Peace,
Bill


Asus GF63 8RD, I-7 8850H, 32GB RAM, 1TB SSD, 2TB HDD, NVIDIA GTX 1050Max
Samsung S9+, 64GB
Fire 10HD 64GB 7th Gen

Posts 6
Nancy Dyck | Forum Activity | Replied: Mon, Sep 28 2015 1:07 PM

I'm new to VBA in word and would greatly appreciate seeing an example that finds and changes both text and style if you happen to have a simple example around.

Blessings.

(this was posted by my husband so please reply to him at )lbdyck@gmail.com

Posts 157
James William Roberts, Jr. | Forum Activity | Replied: Mon, Sep 28 2015 7:02 PM

I too would be interested in the user form and more information.

https://sites.google.com/a/oldpaths.org.uk/oldpaths-the-sword-of-the-spiritthe-word-of-god--eph-617b/personal-books/jamesroberts-docx

Page 1 of 1 (11 items) | RSS