![]() |
Excel's VBA < Word's VBA?
I program using VBA for Word. I've imported some forms and code from a
Word project into Excel, but there are lots of issues. Is there a web page I can go to to help distinguish the many differences between VBA for Excel and VBA for Word? Thanks. |
Excel's VBA < Word's VBA?
Sonny,
The actual VBA used by Excel and Word is the same. The difference lies in the object models of the Excel and Word applications. Aside from books about Word and Excel programming, you can use the Object Browser to see the object models. Perhaps you could start by asking specific questions. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Sonny Maou" wrote in message ... I program using VBA for Word. I've imported some forms and code from a Word project into Excel, but there are lots of issues. Is there a web page I can go to to help distinguish the many differences between VBA for Excel and VBA for Word? Thanks. |
Excel's VBA < Word's VBA?
Chip Pearson wrote:
Sonny, The actual VBA used by Excel and Word is the same. The difference lies in the object models of the Excel and Word applications. Aside from books about Word and Excel programming, you can use the Object Browser to see the object models. Perhaps you could start by asking specific questions. Thanks, Chip. I wanted to RTFM before I got into specific questions... |
Excel's VBA < Word's VBA?
Chip Pearson wrote:
Perhaps you could start by asking specific questions. Chip, the following code works in Word. Why doesn't it work in Excel? If they are the "same VBA," why doesn't the constant wdUserTemplatesPath work in Excel like it does in Word? How would the code below need to be written to work in Excel? Public Function dirPath(x) Dim temp If x = "user" Then temp = Options.DefaultFilePath(wdUserTemplatesPath) Else temp = Options.DefaultFilePath(wdWorkgroupTemplatesPath) End If dirPath = temp End Function Thanks! :) |
Excel's VBA < Word's VBA?
Joe wrote:
Hi Sonny, First, the constants defined in the Word library are not defined in the Excel library and vice versa. Well, that blows, since those same constants would seem to be shareable at least within Office apps. Second, Options.DefaultFilePath has no meaning in the Excel Object Model. What are you trying to do? Firstly, I'm trying to get the "default file path" for user templates and workgroup templates. Now that I look around Excel's ToolsOptions dialog box, I see that there is no place to specify these locations. :/ Ultimately, I'm trying to convert some document management code that has been developed for Word documents into worksheet management code that works in Excel... looks like it's going to be a long haul. :( Thanks for your help! :) |
Excel's VBA < Word's VBA?
Sonny: For the same reason a Ford key won't work in a Chevy. While the
engines both burn gas, the "keys" to make them run are different. So, too, Excel and Word are different in what they do and how they do it, and the commands needed to instruct the different programs to function. The prefix "wd" is a dead giveaway that the instruction or parameter is specific to Word. Ed "Sonny Maou" wrote in message ... Chip Pearson wrote: Perhaps you could start by asking specific questions. Chip, the following code works in Word. Why doesn't it work in Excel? If they are the "same VBA," why doesn't the constant wdUserTemplatesPath work in Excel like it does in Word? How would the code below need to be written to work in Excel? Public Function dirPath(x) Dim temp If x = "user" Then temp = Options.DefaultFilePath(wdUserTemplatesPath) Else temp = Options.DefaultFilePath(wdWorkgroupTemplatesPath) End If dirPath = temp End Function Thanks! :) |
Excel's VBA < Word's VBA?
Ed so kindly wrote:
Sonny: For the same reason a Ford key won't work in a Chevy. Well, a Ford engine will work in a Chevy, with a little mod... maybe that's a better analogy. or maybe not. :/ engines both burn gas, the "keys" to make them run are different. So, too, Excel and Word are different in what they do and how they do it, and the commands needed to instruct the different programs to function. The prefix "wd" is a dead giveaway that the instruction or parameter is specific to Word. Yeah, I was hopin' for some real live compatibility between two Microsoft Office apps. heh. Some may say I'm a dreamer... :) Of course, I see the need for specific and necessarily incompatible objects to represent each app's "docs"... I'm just bein' a whiner for a moment. Thank you. :P |
Excel's VBA < Word's VBA?
You can certainly automate on Office application from another.
They work together quite nicely in that respect. In VBA, go to the Tools menu, choose References, and select the Microsoft Word object library. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Sonny Maou" wrote in message ... Ed so kindly wrote: Sonny: For the same reason a Ford key won't work in a Chevy. Well, a Ford engine will work in a Chevy, with a little mod... maybe that's a better analogy. or maybe not. :/ engines both burn gas, the "keys" to make them run are different. So, too, Excel and Word are different in what they do and how they do it, and the commands needed to instruct the different programs to function. The prefix "wd" is a dead giveaway that the instruction or parameter is specific to Word. Yeah, I was hopin' for some real live compatibility between two Microsoft Office apps. heh. Some may say I'm a dreamer... :) Of course, I see the need for specific and necessarily incompatible objects to represent each app's "docs"... I'm just bein' a whiner for a moment. Thank you. :P |
Excel's VBA < Word's VBA?
Dave Peterson wrote:
For excel: MsgBox Application.DefaultFilePath MsgBox Application.NetworkTemplatesPath MsgBox Application.TemplatesPath And the only place I've seen where the Network templates path can be set by the user is within word--but excel respects that setting. Thank you, Dave... my first step toward cross-application compatibility! :) |
All times are GMT +1. The time now is 05:32 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com