Word XP MACRO ! ... err now what ?????

R

Richard White

I have been given a Macro (source code) for Word (I use Word XP).

What *exactly* do I now do to install/run the thing?

The macro writer gave me the following cryptic steps, but I am not seeing what he expects me to see,
so I can't use them:-

When in Word: Tools->Macro->VB
Click on run
type a name in the box
then it opens up with
Sub ()
End Sub
Simply copy program code via Notepad

Things go awry after Tools->Macro

I don't have "VB", but I do have "Visual Basic Editor", so I've selected that. In the blank window
that then appears I have clicked on "Run", and sussed out how to create a new macro; pasted in the
code, and saved the whole document.

On re-editing the macro is still there!!! But won't work.

An initial statement of "zz = 0" fails as "Invalid outside procedure"

So I notice that the "Sub ()" and "End Sub" aren't present as per instructions, so I added them
before/after all the code, and now get error "Expected: identifier".

Only other thing I can think of is to say 'where-I-am' in Word. I'm 'in' the macro editing, in an
edit window with title of "MyMacro - UserForm1(code)", and with a couple of one liner pull-downs
above the code: top-left = "(General)" and top-right = "(Declarations)".

errrr ..... how DO I get the macro to install/run?
 
G

garfield-n-odie

Hi, Richard White. The macro should look something like:

Sub NameYouGaveThisMacro()
Body of Macro
End Sub
 
B

Beth Melton

Hi Richard,

Try the following:

- Copy the lines of code between Sub and End Sub (if they are present)
- In Word go to Tools/Macro/Macros
- Provide a name for your macro (no spaces)
- Click the "Create" command
- Paste the code between Sub and End Sub
- Delete all other failed attempts. :)

If you need more information then take a look at this article:
http://word.mvps.org/FAQs/MacrosVBA/CreateAMacroContent.htm
--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/


Richard White said:
I have been given a Macro (source code) for Word (I use Word XP).

What *exactly* do I now do to install/run the thing?

The macro writer gave me the following cryptic steps, but I am not
seeing what he expects me to see,
so I can't use them:-

When in Word: Tools->Macro->VB
Click on run
type a name in the box
then it opens up with
Sub ()
End Sub
Simply copy program code via Notepad

Things go awry after Tools->Macro

I don't have "VB", but I do have "Visual Basic Editor", so I've
selected that. In the blank window
that then appears I have clicked on "Run", and sussed out how to
create a new macro; pasted in the
code, and saved the whole document.

On re-editing the macro is still there!!! But won't work.

An initial statement of "zz = 0" fails as "Invalid outside procedure"

So I notice that the "Sub ()" and "End Sub" aren't present as per instructions, so I added them
before/after all the code, and now get error "Expected: identifier".

Only other thing I can think of is to say 'where-I-am' in Word.
I'm 'in' the macro editing, in an
 
R

Richard White

Beth Melton said:
Hi Richard,

Try the following:

- Copy the lines of code between Sub and End Sub (if they are present)
- In Word go to Tools/Macro/Macros
- Provide a name for your macro (no spaces)
- Click the "Create" command
- Paste the code between Sub and End Sub
- Delete all other failed attempts. :)

Ummm .... done all this and looked at your web link. Still no go!

The macro is in a window entitled "NutteingMacro01 - Module1(code)"

Immediately under window title have
on left: "(General)" on right: "NutteingMacro01"

Then comes the main 'box' with the macro in it. It now looks like:-

Sub NutteingMacro01()

' 20 founding families
' Generating 10 loci x2 profiles
' to be called on later
' 2 +3 +9 +27 +81 +243 = 365 = profiles
' repeated xx (20) times
' the whole routine up to final single allele
' matches repeated tt (20 ) times

zz = 0
Dim ph(20)
Dim ps As String
Dim pg0(365, 20)
' pg8 is 20 founding families from which to select the pg0 file
Dim pg8(20, 1095)
etc. ... for many many lines until
End Sub

The error is "Compile Error:
Invalid outside procedure"

When this happens, a new window as appeared entitled "NutteingMacro01 - UserForm1(code)"
underneath the lhs is same, but rhs is now "(Declarations)"
the macro *minus* the "Sub NutteingMacro01()" appears in the window main box,
and the "0" is highlighted in the statement "zz = 0" above.

I'm assuming that the macros works at all having come from a web site.
So, what is wrong?
What do I do to fix it?
 
B

Beth Melton

Hi Richard,



I may have found the macro, or a version of it, on the Internet and I
was able to correct the errors and run it, but since it goes beyond a
Punnett square (??) I couldn't tell you what I was looking at in the
data files it generated. ;-)



Why don't you copy/paste the entire macro, or provide a link to the
macro, you are using and we'll have a look at it. Based on what I
found there were several lines that should have been commented along
with several macros that appeared to be one macro.


--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/


Ummm .... done all this and looked at your web link. Still no go!

The macro is in a window entitled "NutteingMacro01 - Module1(code)"

Immediately under window title have
on left: "(General)" on right: "NutteingMacro01"

Then comes the main 'box' with the macro in it. It now looks like:-

Sub NutteingMacro01()

' 20 founding families
' Generating 10 loci x2 profiles
' to be called on later
' 2 +3 +9 +27 +81 +243 = 365 = profiles
' repeated xx (20) times
' the whole routine up to final single allele
' matches repeated tt (20 ) times

zz = 0
Dim ph(20)
Dim ps As String
Dim pg0(365, 20)
' pg8 is 20 founding families from which to select the pg0 file
Dim pg8(20, 1095)
etc. ... for many many lines until
End Sub

The error is "Compile Error:
Invalid outside procedure"

When this happens, a new window as appeared entitled
"NutteingMacro01 - UserForm1(code)"
 
R

Richard White

[...snipped...]
Why don't you copy/paste the entire macro, or provide a link to the
macro, you are using and we'll have a look at it. Based on what I
found there were several lines that should have been commented along
with several macros that appeared to be one macro.

Hi - I thought of that too, and sent a further posting, but obviously you didn't see that one.
Here's the link again.

http://www.nutteing.50megs.com/dnas4.htm

Maybe it's a compatibility (older/newer version of Word) or a programming error?

Who knows? I certainly don't LOL.
 
B

Beth Melton

Hi Richard,

I see the second reply now. :)

This specific macro copy/pasted and ran fine.

However if you have "Option Explicit" in the General Declarations of
the module then you will encounter a "variable not defined' error
since several variables are not declared so you will need to remove
Option Explicit.

I didn't see a UserForm in the sample so I'm wondering if somehow you
accidentally inserted a UserForm and added the code without the
Sub/End Sub.

Here's what I want you to do:
- In the Project Explorer (on the left at the top) if the "Toggle
Folders" command is turned on (pushed in) click it to turn it off.
- If you see a UserForm, right-click the object and select "Remove"
- Remove all other modules you may have created with the exception of
Module1
- Verify Module1 contains your Nutteing macro and the code is place
inside of Sub NutteingMacro01...End Sub
- Remove Option Explicit if present at the top of the module
- Try running the macro again (place your cursor in the code and press
F5)

Note the resulting text files will be placed in your current folder.
IOW, if you want all of the files to be placed in a specific folder
then make sure you navigate to the folder in File/Open, you don't need
to open a file - just click the Close (x) button, before running the
macro.

--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/


Richard White said:
[...snipped...]
Why don't you copy/paste the entire macro, or provide a link to the
macro, you are using and we'll have a look at it. Based on what I
found there were several lines that should have been commented along
with several macros that appeared to be one macro.

Hi - I thought of that too, and sent a further posting, but
obviously you didn't see that one.
 
R

Richard White

[...snipped...]
Here's what I want you to do:
- In the Project Explorer (on the left at the top) if the "Toggle
Folders" command is turned on (pushed in) click it to turn it off.

.... you've lost me already! Where are you within Word for this starting point?

To make it easier, I've deleted the whole Word doc containing macro so I can start again.

[...snipped...]
Note the resulting text files will be placed in your current folder.
IOW, if you want all of the files to be placed in a specific folder
then make sure you navigate to the folder in File/Open, you don't need
to open a file - just click the Close (x) button, before running the
macro.

Are you here talking about the File menu in the main Word program?
Do you mean Close the current doc window?
If so - how would I run the macro (assuming I can get over the hurdle of getting it working)?
 
R

Richard White

[...snipped...]
Here's what I want you to do:
- In the Project Explorer (on the left at the top) if the "Toggle
Folders" command is turned on (pushed in) click it to turn it off.

.... you've lost me already! Where are you within Word for this starting point?

To make it easier, I've deleted the whole Word doc containing macro so I can start again.

[...snipped...]
Note the resulting text files will be placed in your current folder.
IOW, if you want all of the files to be placed in a specific folder
then make sure you navigate to the folder in File/Open, you don't need
to open a file - just click the Close (x) button, before running the
macro.

Are you here talking about the File menu in the main Word program?
Do you mean Close the current doc window?
If so - how would I run the macro (assuming I can get over the hurdle of getting it working)?

As you can see - I really do know nothing about macros in Word, or even anything about their
development/run environment. Is there a *simple* guide online with graphical examples of the step
by step screens for using someone else's macro?

The linke I was given earlier gave a text description, but no screenshots.

Likewise, is there something which will give an equally *simple* explanation of the environment?
Projects/forms explained etc? Overview level description of the macro/VB system?
 
B

Beth Melton

Richard White said:
[...snipped...]
Here's what I want you to do:
- In the Project Explorer (on the left at the top) if the "Toggle
Folders" command is turned on (pushed in) click it to turn it off.

... you've lost me already! Where are you within Word for this
starting point?

This is in the Visual Basic Editor.
To make it easier, I've deleted the whole Word doc containing macro
so I can start again.

That's probably the best route.
[...snipped...]
Note the resulting text files will be placed in your current folder.
IOW, if you want all of the files to be placed in a specific folder
then make sure you navigate to the folder in File/Open, you don't need
to open a file - just click the Close (x) button, before running the
macro.

Are you here talking about the File menu in the main Word program?

Since there is no File/Open in the Visual Basic Editor then by process
of elimination it's the main Word application window.
Do you mean Close the current doc window?

No, click the Close button on the File/Open dialog box.
If so - how would I run the macro (assuming I can get over the
hurdle of getting it working)?

Please note my last step:

- Try running the macro again (place your cursor in the code and press
F5)


--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 
B

Beth Melton

As you can see - I really do know nothing about macros in Word, or even anything about their
development/run environment. Is there a *simple* guide online with graphical examples of the step
by step screens for using someone else's macro?

Sorry, not that I know of. :-(
The linke I was given earlier gave a text description, but no
screenshots.

I agree, screen shots could be helpful but the text is pretty straight
forward: Go to Tools/Macro/Macros, type a name for your macro, click
Create and paste the copied code between Sub/End Sub.
Likewise, is there something which will give an equally *simple*
explanation of the environment?
Projects/forms explained etc? Overview level description of the
macro/VB system?

There are several tips/tutorials found here:
http://word.mvps.org/FAQs/MacrosVBA.htm#BeginnersTips

But other than getting yourself a good manual I don't know of a
'simple' explanation for VBA and the Visual Basic Editor. This would
be similar to me asking you for a simple explanation of how to utilize
the results of the macro you are using. ;-)

Perhaps someone else has some recommended links for you.
--
Please post all follow-up questions to the newsgroup. Requests for
assistance by email can not be acknowledged.

~~~~~~~~~~~~~~~
Beth Melton
Microsoft Office MVP

Word FAQ: http://mvps.org/word
TechTrax eZine: http://mousetrax.com/techtrax/
MVP FAQ site: http://mvps.org/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top