Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetObject to Open Word containing Macros
From examples of retrieving information held with a Form in Microsoft Word, I have a macro that opens up a collection of forms to update a register held within Excel It all works provided that either the word forms do not contain macros or I sit there and click Disable or Enable Macros for every form. Is there any way to tell Word to Get the forms without activating the Macros? - Or always activating them as it makes no difference to the information being retrieved and wont be run by just opening Set Wd = GetObject(Range("RFI_Location").Value & ImportForm) where RFI_Lacation is the Filepath & ImportForm is the Filename (from a macro that seaches the Filepath for the forms) Is there another method that I should use, if GetObject isnt the right one? Thanks very much for any help that anyone can give. Kris |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetObject to Open Word containing Macros
When you 'automate' Word and open a document with macros you should not get the macro security warning. Try something like this Sub test() Dim sDoc As String Dim objWd As Object Dim objDoc As Object sDoc = "C:\< path \testDoc with macro.doc" On Error Resume Next Set objWd = GetObject(, "word.application") On Error Resume Next If objWd Is Nothing Then Set objWd = CreateObject("word.application") End If objWd.Visible = True Set objDoc = objWd.documents.Open(sDoc) AppActivate objWd.Caption ' lazy way to make it active objWd.Run ("myMacro") ' a macro in the word document End Sub GetObject will attempt to find a running instance of Word (might even be your Outlook email editor). If it fails use CreateObject to start your own. You might also want an extra flag so you'll know to quit the new instance when done, not included above. Regards, Peter T "Kris_Wright_77" wrote in message ... From examples of retrieving information held with a Form in Microsoft Word, I have a macro that opens up a collection of forms to update a register held within Excel It all works provided that either the word forms do not contain macros or I sit there and click Disable or Enable Macros for every form. Is there any way to tell Word to Get the forms without activating the Macros? - Or always activating them as it makes no difference to the information being retrieved and wont be run by just opening Set Wd = GetObject(Range("RFI_Location").Value & ImportForm) where RFI_Lacation is the Filepath & ImportForm is the Filename (from a macro that seaches the Filepath for the forms) Is there another method that I should use, if GetObject isnt the right one? Thanks very much for any help that anyone can give. Kris |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
GetObject to Open Word containing Macros
Thanks very much Using CreateObject stopped the macro security warning popping up "Peter T" wrote: When you 'automate' Word and open a document with macros you should not get the macro security warning. Try something like this Sub test() Dim sDoc As String Dim objWd As Object Dim objDoc As Object sDoc = "C:\< path \testDoc with macro.doc" On Error Resume Next Set objWd = GetObject(, "word.application") On Error Resume Next If objWd Is Nothing Then Set objWd = CreateObject("word.application") End If objWd.Visible = True Set objDoc = objWd.documents.Open(sDoc) AppActivate objWd.Caption ' lazy way to make it active objWd.Run ("myMacro") ' a macro in the word document End Sub GetObject will attempt to find a running instance of Word (might even be your Outlook email editor). If it fails use CreateObject to start your own. You might also want an extra flag so you'll know to quit the new instance when done, not included above. Regards, Peter T "Kris_Wright_77" wrote in message ... From examples of retrieving information held with a Form in Microsoft Word, I have a macro that opens up a collection of forms to update a register held within Excel It all works provided that either the word forms do not contain macros or I sit there and click Disable or Enable Macros for every form. Is there any way to tell Word to Get the forms without activating the Macros? - Or always activating them as it makes no difference to the information being retrieved and wont be run by just opening Set Wd = GetObject(Range("RFI_Location").Value & ImportForm) where RFI_Lacation is the Filepath & ImportForm is the Filename (from a macro that seaches the Filepath for the forms) Is there another method that I should use, if GetObject isnt the right one? Thanks very much for any help that anyone can give. Kris |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
embeded excel control doesn't work properly if excel workbook is open through GetObject("xx.xls") | Excel Programming | |||
Open workbook-macros enabled, opening another with macros | Excel Programming | |||
Making excel macros run Word macros | Excel Programming | |||
Macro Size Limit / open macros with macros? | Excel Programming |