#1
|
|||
|
|||
Where does my code go?
I'm working on my first macro. word 2007
Where do i put my code? I'm in the vb project explorer and i see that i can add a module, or double click on ThisDocument and have another code window. So do i have 2 places where code can go. is there a purpose for each or does it matter? Why would i need to add a module if ThisDocument has a code window? Pretty basic i guess. Is there a reference for this stuff? A web resource? a Getting started tutorial? |
#2
|
||||
|
||||
Hi rbaldwin,
Typically, code that isn't specifically related to 'Document' events goes into one or more separate code modules (you might use multiple code modules for grouping related projects and keeping them separate from other projects). If you want to see what those are, open the 'ThisDocument' module, select 'Document' from the left-hand dropdown above the code pane, then take a look at the contents of the right-hand dropdown. Also, if you create a userform, the code for that should generally go into the userform's code module.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks, i appreciate the explanatation.
Is there a reference you'd recommend? |
#4
|
||||
|
||||
There are many web sites with tutorials, and you might one or two of them worth doing. Most are probably for Excel, so you might want to think carefully about whether you'd want to do one of those.
For a book, you might try something like 'The Secret Life of Word: A Professional Writer's Guide to Microsoft Word Automation' by R Delwood. This isn't a programming book, and doesn't profess to teach you how to program. Rather, it shows how to combine Word's various tools to achieve whatever the desired result might be. The only reason I can suggest this book is that I did much of the technical review; I'm sure there are plenty of others out there. Another that I contributed to is 'Word Hacks', by A Savikas, but that one pre-dates Office 2007.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
vbc code | rajpeter | Excel Programming | 2 | 09-13-2011 02:29 PM |
vba code in excel | rajpeter | Excel Programming | 5 | 09-11-2011 06:13 PM |
VBA code to change | carlleese24 | Excel Programming | 2 | 08-13-2011 09:48 AM |
Word07-Bid Tab Code | ddw23 | Word VBA | 0 | 07-28-2011 01:07 PM |