Hello and welcome to Just Answer. I can help you with this. Do you have a spreadsheet that this Macro will be used on. I need to see the layout so I can write the code to work with your structure.
No it isn't in a spreadsheet - it would be run in a Word document.
Do you have the Word doc that you will be using the Macro with? I can try to write the Macro in the blind, but it would be easier if I had something to reference
Yes I have a sample of something.
It will not be the same document every time; I work in a hospital pathology department where standard text when describing a specimen but the measurements change with each specimen.
OK, go to www.wikisend.com upload the file, then post the file ID or download link here so I can work on it this evening.
I built a macro for this in Word 2003 a long time ago but can't remember how I did it - of course Word 2007 is different and moving to Word 2010 at our facility soon.
I can write the macro in 2010 and it will be usable in 2007 and 2010
That would be terrific!! Thank you
Just upload the file so that I have something to reference then send me the link to download it.
Also, this might take me a day or so, so please be patient and I will get back to you as soon as I have a question or something for you to test.
Just sent the file - Example for Macro
Link - http://wikisend.com/download/484880/Example for Macro.docx
OK, I will get to work on this tonight and will have something for you soon
Thanks - look forward to it
Hello. I have written your macro. I wrote it to look specifically for the "#" character. Do you want to be able to change what you are looking for, or will you always look for that character?
The # XXXXX is the one we use.
OK. In order to launch the macro you need to use the "Ctrl-?" key combination (i.e. Ctrl+Shift+/).
I have done two things for you. I have zipped the Word doc that you sent me with the macro already attached so you can just use that doc, and I also zipped up the macro so yo ucan import it into other Word doc's
Can I send it to someone else to import?
We have multiple users who may want this macro
You can download the zip file here.You can send it to someone else to import, but you'll need to zip it up as most emails servers will strip the attachment because macros are often used to spread viruses.
Try it out and let me know if you have any questions
Or you could simply send them the entire Word document
Can't get the macro to invoke
I accessed the Example document and tried Ctrl+Shift+/ - didn't move to the # XXXXX
I wonder if the key combination didn't stay when you opened it...
open the view macros window by looking at (I think) the View tab, them click the down arrow under macros
Could be under the developer tab
Did that - drop down is empty
Developer is empty also
OK, that's strange? When you launched the Word Doc, did it ask you to enable Macros?
Try to import the Macro that I included in the Zip file...Open Visual Basic under the developer tab...Click File Import File, then select the macro that is in the Zip file
It just asks if I want to open the file
Is it still asking if you would like to open the file?
OK. I just tested this on my co-workers Office 2007 Suite
With the Word Doc open, select the Developer tab
Open Visual Basic
In Visual Basic, click File Import File
Import the FindReplaceNext.bas file that I included in the ZIP fie
This will import the macro into the Word Doc
Once it is imported, you can close Visual Basic, then click on the Macros ribbon under the developer tab
You should now see the FindReplaceNext Macro in the list. You can test it by double clicking it in the list
Ok I see it
You will have to assign a shortcut to the macro manually, because aparently the key combination doesn't transfer when you import i
Follow this procedure to assign the shortcut to a key combination:
In the next dialog, scroll down through the Categories list and click on Macros. Now click on the name of a macro in the right-hand list, click in the "Press new shortcut key" box, and press the shortcut you want. Click the Assign button (Important! the shortcut isn't assigned if you just click the Close button without clicking Assign first).
Sorry - had to answer a question. Give me a minute to try this.
When I click on Macros in the Customize>Keyboard Shortcuts - the right hand box is blank
Shouldn't the Find Replace macro be in that box?
It should be
The Save changes in box = Normal.dotm. If I change it to Example for Macro.docx the FindReplaceNext name appears in the box.
Gotcha...So you ar able to assign key combination now...right?
Excellent...How'd the macro work for you?
I entered Ctrl+Shift+/
It should have shown up as Ctrl-? in the assign box
Ok - I closed the document and reopened. Macro is no longer available.
I started from the beginning. Imported the macro, assigned shortcut key.
I did this with the document open.
Cursor is at the beginning of the paragraph. When I invoke the macro it wants a replacement at the beginning of the paragraph. There is nothing to replace.
Type the replacement text and it will replace the # XXXXX whatever you type
once you click OK
The marco will then move to the next #
If I click ok - just closes the replace box. When I try the macro again, still wants a replace value at the beginning of the paragraph. If I move to the first #, replace, hit ok it will move to the next #.
You are using Office 2007, right
I just tested the Macro on both 2010 and 2007 and the Macro works as it should
It isn't asking for a Replace value at the beginning of the paragraph?
I just invoked the macro again - still asking for Replacement Text at the beginning of the paragraph. I hit the space bar and it moved to the # XXXXX
and didn't add the space at the beginning of the paragraph.
Tried to close my document - got the message that I had to save it in a Word macro enabled document, which I did.
Then when I tried to reopen and invoke the macro got an error message that the macro in this project has been disabled.
I went back to my original example - and now no macro!!
Here's what happens when I run the Macro: http://www.mediafire.com/?kprnabasp0s7cbe
I don't know what that means
I see - you are sending me a video
Here's what happens...I place my cursor at the beginning of the document. I press Ctrl+?. The macro opens an input form. I type Test1 the hit enter, the macro replaces the first "#" sign with "Test1", then moves to the next "#" sign. I type Test2 then hit enter, the macro replaces the second "#" sign with "Test2"....so on and so forth. This is what I coded the Macro to do, is this what you were looking for? If not, I can try making changes to suit your exact needs
Ok I see what was happening - and it works but when I close the document (didn't save replace changes) and open it again - the macro is gone - have to start all over with importing from Visual Basic
Once you import the Macro, try pressing the save button in Visual Basic.
Its telling me it can't save unless I save it in a macro-enabled file type
Yes...that's what you need to do
Then I don't think this is going to work for me. We use an application that uses Word as a template which I can't change.
What format does the fie need to be in?
Currently, I am using the macro that I designed in a Word Doc that has the .docx file extension
I honestly can't tell you that.
Our reports are not save to Word files.
But your files start out as Word files right?
Our files are save to our application not in .docx
I'm not the IT expert on where our files are saved - so I'm probably giving you misinformation. I really appreciate all your help.
Well, now you have a Macro that you can use on other Word documents. ;-)