See my code in IDE?????

T

Tom_OM

I guess I'll just have to risk looking foolish. I have a few years
experience with VB 6, and so I figured it would be a snap to dive
right into VBA to create Word macros. I've recorded them and assigned
each one to a hot key with no trouble.

However, I'm having difficulty in opening my code. In regular VB 6,
I've always clicked on the "view code" icon to see my code, and it's
always worked with no problem. However, it's not working in the VBA
IDE for some reason. I understand my macro code is in the normal.dot
file. Unfortunately, the VBA IDE does not seem to want to let me view
the code I've just recorded. Frustrating!

Here's what I'm seeing:
http://www.renamestar.com/wordproshots/vbaide2.htm

When I've clicked on "Normal", the View Code icon is grayed out.
Makes sense. What doesn't make sense is when I click on "NewMacros"
the View Code button un-grays as if I could click on it to see my code
(as seen in my illustration). I do so, but nothing happens -- no
error message, nothing.

If I click on anything else under "Normal", (This Document, UserForm1,
etc.) it also acts as if I can click on View Code to see my macros'
code, but I have no luck with that either. I'm using Word XP under
Windows XP Pro. I also tried the same thing with Word 2K, which is
also on my system, but I had the same frustration.

What am I missing? Is there something wrong with my install of Office
XP? Is there some kind of security setting that I have to change?
I'm stumped.
 
S

Shauna Kelly

Hi Tom

Try double-clicking the module name in the Project Explorer. That should
open up the code in a large white pane on the right.
I figured it would be a snap to dive
right into VBA to create Word macros

You're not the first one to have jumped to that conclusion!

The following might help:

Getting To Grips With VBA Basics In 15 Minutes
http://www.word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm

How to modify a recorded macro
http://www.word.mvps.org/FAQs/MacrosVBA/ModifyRecordedMacro.htm

and in general, see the articles at:

Word MVP FAQ - Macros/VBA
http://www.word.mvps.org/FAQs/MacrosVBA.htm

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
T

Tom_OM

Thanks for the help, Shauna (and those links as well as your site look
useful). Unfortunately, I'm still not having any luck. Now just to
be certain I'm not wacked-out, the Project Explorer is what I've shown
in my screenshot, right?
screen shot: http://www.renamestar.com/wordproshots/vbaide2.htm

When I double click on "Normal" the sub-categories "NewMacros,"
ThisDocument, UserForm1, etc. come up. When I double click on any of
those, I get no code window. When I double click on "ThisDocument,"
the Properties index does come up, but no code does.

If I right click on the same items and choose "View Code," I also get
nothing. I wondered if some of the add-ins I have installed somehow
conflicted. These are my add-ins (which you can also see in the
screenshot of my Project Explorer:

Project (DVZWDAddin
TemplateProject (Bs2000)
WordStar_Template (WordStar)
I tried disabling all of these, but still couldn't get the code to
view.

Am I doing everything right? Is my install of Word somehow flawed?
That's hard to believe since I have the same problem in Word 2K as I
do in Word XP. The only difference I saw between these two apps was
that the WordStar_Template add-in did not load in Word 2K. I don't
know if that's relevant.

Also, if I click on any of the add-ins, I get the message "Project is
unviewable," which should not be a problem since I want to edit my own
code, not the code of the authors of those add-ins. Plus, if I
disable the add-ins, I still can't view my own code. That leads me to
believe that the add-ins aren't the problem.

Frustrated. Arg.

Any ideas?
 
S

Shauna Kelly

Hi Tom
"Project is unviewable,"

If an add-in is loaded (ie a .dot file is listed and ticked at Tools >
Templates and Add-ins), then it is not thereby viewable or editable in the
VBE.

You have to do File > Open and actually open the .dot file, and then use the
VBE to work with the open file. (Don't just double-click in Windows
Explorer; that will create a new document based on the .dot file, which
won't hold your code, and isn't what you need.)

Apart from that, I would suggest using Start > Run and running "winword.exe
/a" (no quotes). This will start Word without any add-ins. This is what
happens if I do that:

After opening, I see a blank document. I do Alt-F11. I can see the Project
Explorer (yes, what you show in your screen shot), showing Normal and
Project (Document 1) with "This Document" highlighted. I double-click it,
and the large white code pane opens. Type some text in the big white pane,
so you can distinguish it from other code.

I can do Insert > Module and Word will insert a Module1 into Modules under
Project (Document 1). However, I can only go back and forth between viewing
the code in ThisDocument and the code in Module1 by double-clicking.

If all is OK having opened Word with the /a switch, then you can safely
assume that any problems are being caused by the add-ins.

For what it's worth, I find it useful to unload all add-ins when I'm coding
(well, except for little tools I've created for myself). Otherwise, you
don't know whether the UI or Word's behaviour is coming from Word or from
the add-in.

Hope this helps.

Shauna Kelly. Microsoft MVP.
http://www.shaunakelly.com/word
 
J

Jay Freedman

Hi Tom,

By default, both the Project Explorer and the Properties pane are
docked only to the left side of the IDE and are only about 1/3 of the
width of the window. I think what's happening is that the code window
is hidden behind your full-width panes. If so, it will be listed in
the Window menu.

Try right-clicking a blank area in the Project Explorer and unchecking
the Dockable item in the context menu. Then resize it to 1/3 the width
and 1/2 the height of the IDE, and turn on Dockable again -- it should
dock to the left side. Do the same with the Properties pane. Then you
can maximize the code window, which will take the remaining space.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 
T

Tom_OM

Success, at last. I can open up my code now. Shauna and Jay, thank
you very much for your help. The code window must have somehow gotten
hidden, but I couldn't find it. I ended up uninstalling and
reinstalling Office XP. After I then opened up Word, it burped and
couldn't load the WordStar add-in, so it asked if I wanted to delete
it. I chose Yes, and then the code window would come up when I
clicked View Code.

I was worried that it was the add-in's fault and I therefore wouldn't
be able to use it. However, when I reinstalled it, it worked without
making me unable to view the code. Thank goodness because that's an
add-in I really want to use. (If you're curious, here's where I got
it: http://www.wordstar.org/wsemu/word/pages/intro.htm).
 

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