Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
embeded excel control doesn't work properly if excel workbook is open through GetObject("xx.xls") Zhiming H Excel Programming 2 October 28th 08 01:22 PM
Open workbook-macros enabled, opening another with macros George J Excel Programming 5 September 17th 04 02:07 PM
Making excel macros run Word macros Matthew McManus Excel Programming 1 February 18th 04 02:57 AM
Macro Size Limit / open macros with macros? andycharger[_7_] Excel Programming 6 February 13th 04 02:00 PM


All times are GMT +1. The time now is 03:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"