Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2012, 02:32 AM
ximpostor ximpostor is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2003
Novice
can I run a macro when I open a specific doc ??
 
Join Date: Oct 2012
Posts: 8
ximpostor is on a distinguished road
Exclamation can I run a macro when I open a specific doc ??

Hi there

I have a word doc of which I wanna run a macro automatically when it opens. I need it to open an object.. i inserted it to this doc file.



Can this be done ??
Reply With Quote
  #2  
Old 10-09-2012, 05:15 AM
macropod's Avatar
macropod macropod is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,235
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Yes. See: http://www.word.mvps.org/FAQs/Macros...mentEvents.htm
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-09-2012, 02:53 PM
ximpostor ximpostor is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2003
Novice
can I run a macro when I open a specific doc ??
 
Join Date: Oct 2012
Posts: 8
ximpostor is on a distinguished road
Default

thanks alot but how to order it to open an object inserted in this word file ??

like this file.xlsx ??
Reply With Quote
  #4  
Old 10-09-2012, 03:01 PM
macropod's Avatar
macropod macropod is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,235
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Referencing embedded OLE objects doesn't use filenames - it uses shape or inlineshape references, such as:
Code:
Dim objOLE As Word.OLEFormat
Set objOLE = ActiveDocument.InlineShapes(1).OLEFormat
objOLE.Activate
The above code assumes the embedded object is the first InlineShape in the document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-09-2012, 03:39 PM
ximpostor ximpostor is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2003
Novice
can I run a macro when I open a specific doc ??
 
Join Date: Oct 2012
Posts: 8
ximpostor is on a distinguished road
Default

"you are about to activate an embedded object that may contain viruses or be otherwise harmful to your computer"

How can i hide this message or auto accept it on my pc ??

i'll open this file too much & add it to the startup folder .. this message will distribute me !!
Reply With Quote
  #6  
Old 10-09-2012, 03:47 PM
ximpostor ximpostor is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2003
Novice
can I run a macro when I open a specific doc ??
 
Join Date: Oct 2012
Posts: 8
ximpostor is on a distinguished road
Default

-----------------------
Dim TaskID As Long
TaskID = Shell ("file.xlsx", vbNormalFocus)
-----------------------

i got this code but i cant edit it to open an contained object !! it always open a file from my hard disk !!
Reply With Quote
  #7  
Old 10-09-2012, 04:02 PM
macropod's Avatar
macropod macropod is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,235
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

According to http://support.microsoft.com/kb/291912:
"This feature is designed into Microsoft Office to help protect you from malicious code."
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 10-10-2012, 11:00 AM
ximpostor ximpostor is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2003
Novice
can I run a macro when I open a specific doc ??
 
Join Date: Oct 2012
Posts: 8
ximpostor is on a distinguished road
Default

ok tell me how to open 2 objects in the same time ??

when i open the word file automatically open 2 objects ?? ,,

& Thank U very much ,,
Reply With Quote
  #9  
Old 10-10-2012, 02:24 PM
macropod's Avatar
macropod macropod is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,235
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

AFAIK Word can only have one object opened at a time.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #10  
Old 10-12-2012, 12:32 PM
ximpostor ximpostor is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2003
Novice
can I run a macro when I open a specific doc ??
 
Join Date: Oct 2012
Posts: 8
ximpostor is on a distinguished road
Default

Why when i use this code


------------------------------------
Dim objOLE As Word.OLEFormat
Set objOLE = ActiveDocument.InlineShapes(1).OLEFormat
objOLE.Activate
------------------------------------

Show me this message



And if i choose "No" This error appears ??



please help me ,,
Reply With Quote
  #11  
Old 10-12-2012, 12:35 PM
macropod's Avatar
macropod macropod is offline can I run a macro when I open a specific doc ?? Windows 7 64bit can I run a macro when I open a specific doc ?? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,235
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

You get the error message because your code has no error handling.

Cross-posted at: http://www.vbaexpress.com/forum/showthread.php?t=43982
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
can I run a macro when I open a specific doc ?? Macro to replace one specific heading style with another ubns Word VBA 44 09-04-2012 08:17 PM
can I run a macro when I open a specific doc ?? Need VBA For Macro On How To Remove Specific Words netchie Word VBA 6 08-28-2012 03:37 PM
can I run a macro when I open a specific doc ?? Using Hyperlink to open Word Document at Specific Header rossi45 Word 2 05-04-2012 06:03 PM
can I run a macro when I open a specific doc. shreked Word 8 01-12-2012 03:36 AM
can I run a macro when I open a specific doc ?? Macro for highlighting specific number of words icsjohn Word VBA 2 12-07-2011 06:44 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft