View Single Post
 
Old 06-09-2014, 01:43 PM
BobBridges's Avatar
BobBridges BobBridges is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: May 2013
Location: USA
Posts: 700
BobBridges has a spectacular aura aboutBobBridges has a spectacular aura about
Default

SarahBear, you may need to be more explicit but maybe not: The good news is that a Word module is an Excel module. That is, the code in both is the same.

Ok, now that I've been all exuberant I guess I should tone it back some. There is a difference, but only in a way. Here's the claim phrased more cautiously: Both are written in VBA, and it's possible to write VBA code that can be transfered directly from one Office product to another and run without any changes whatsoever.

The big difference, maybe the only difference, is that a VBA program running in Excel is subject to different default assumptions than the one in Word. For instance, in an VBA/Excel program when I refer to the Application object, it assumes of course that I mean the Excel Application; equally of course, Word would assume I mean the Word Application. But it's perfectly possible to write code—I occasionally write code myself—that executes in Excel and interacts with Excel objects but also opens the Word Application and pulls data from or writes data to Word.

Now, I write for Excel and Access more often than Word, so every time I want to (for example) export Excel data to Word, I have to work at it to remember how the Word object works. I went to find a bit of sample code just now, intending to demonstrate the process, but it isn't where I expected to find it; I don't think I lost it, just misplaced it. But I've done it a few times, and maybe the above is all you need in order to do it for yourself. If not, ask more questions and I'll work on it with you; I need more practice at it anyway.
Reply With Quote