Warning

 

Close
Confirm Action

Are you sure you wish to do this?

Cancel Confirm
AR15.COM
2/25/2008 7:51:20 AM EDT
OK, I have a macro embedding a Word Doc into Excel, and displaying it as an Icon.

BUT...


It opens Word when I insert it, and I cant figure out how to close the word window from VB.

I need to close it so I can finish a loop and run another iteration of the step.

Any ideas?
2/26/2008 1:15:00 AM EDT
[#1]
wordobject.visible=false might help.

Post the code and I might be able to help.

ETA: check your IM.
2/26/2008 9:06:48 AM EDT
[#2]
Ok, here is the code.



ActiveSheet.OLEObjects.Add(ClassType:="Word.Document.8", Link:=False, _
       DisplayAsIcon:=True, IconFileName:= _
       "C:\WINDOWS\Installer\{90110409-6000-11D3-8CFE-0050048383C9}\wordicon.exe", _
       IconIndex:=0, IconLabel:="Microsoft Word Document").Activate
   
   Selection.ShapeRange.ScaleWidth 1.43, msoFalse, msoScaleFromTopLeft
   Selection.ShapeRange.ScaleHeight 0.24, msoFalse, msoScaleFromTopLeft
 


This inserts a word document as an Icon, and then the last two lines are to resize the Icon to match the cells I have in the sheet.

I can get the .doc inserted, but it will not continue to the resizing because a word doc comes up and I cant seem to close it.


Edit-->   Ok, I got it now. I took the "Activate" command off the OLEObject.Add command and replaced it with .Select and all runs fine now. I will not open the Word Doc, and will keep going through the loop.