Hi dreamboat...
your sure Word has Visual Basic for Application??? not Word Basic == this is Words version on Visual basic for Application...
IF so will Excel made VBA scripts run floorless on the Word VBE platform and excecute???
OK you can convet VBA Excel to WB with WB. ----- whatever the syntax is but thats not the same...
Im not Word expert and hardly an Excel expert either but im confused... if im wrong hey thansk for showing me the light always welcom extra knowledge..
Please explain
Hi Jack,
Most of the current Office products (Excel, Word, Access, Outlook, Frontpage) share VBA as their programming language, including Word. WordBasic was the language used by Word to create macros before Word 97. In most cases Word 97 onwards will be able to automatically convert from WordBasic to VBA without the user even knowing.
You say 'will an Excel macro run flawlessly in Word'. Some will, some won't e.g. this will:-
Sub test()
For X = 1 To 5
MsgBox X
Next
End Sub
but this won't:-
Sub test()
ActiveSheet.Range("a1:a10").Formula = "=RAND()"
End Sub
The difference lies in that they have different Object Models. For example Excel has a Workbook, Word has a Document. Both represent an individual file but they are completely different. You can control Word from Excel and Excel from Word (and between many other applications as well) by using a process known as automation. This basically says - 'OK, I am Excel but I'm friends with Word. I want to borrow some functionality of Word (e.g. use Word's thesaurus)'. You can reference Word's object library from Tools, References in the VBE and then create a macro just as though you were programming in Word - although there would be some slight differences because Excel assumes that if you use an unqualified statement e.g.
Application.Quit
then it will assume you want Excel to quit. If you wanted Word to Quit from an Excel macro then you'd use:-
Set WdApp=CreateObject("Word.Application")
WdApp.Quit
OK, those 2 lines of code are COMPLETELY bleeding useless but I hope they illustrate my point.
Anyway, I ranted on for long enough now so I shall get myself off to the pub.
Have a fine evening people,
Dan