Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-13-2012, 08:21 AM
rbaldwin rbaldwin is offline Where does my code go? Windows XP Where does my code go? Office 2007
Novice
Where does my code go?
 
Join Date: Mar 2012
Posts: 2
rbaldwin is on a distinguished road
Default 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?
Reply With Quote
  #2  
Old 03-13-2012, 03:11 PM
macropod's Avatar
macropod macropod is offline Where does my code go? Windows 7 64bit Where does my code go? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
  #3  
Old 03-14-2012, 07:50 AM
rbaldwin rbaldwin is offline Where does my code go? Windows XP Where does my code go? Office 2007
Novice
Where does my code go?
 
Join Date: Mar 2012
Posts: 2
rbaldwin is on a distinguished road
Default

Thanks, i appreciate the explanatation.

Is there a reference you'd recommend?
Reply With Quote
  #4  
Old 03-14-2012, 02:31 PM
macropod's Avatar
macropod macropod is offline Where does my code go? Windows 7 64bit Where does my code go? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where does my code go? 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
Where does my code go? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 07:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft