Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Select Embedded Documents

Does anyone know a code that will select only the embedded documents
on a sheet? I’m trying to setup a code that will copy and paste the
embedded documents to another sheet, but I can’t figure out how to
keep the code from selecting all the other objects on the sheet. I
have Form Buttons, Option Buttons, & embedded PDF, Excel, or Word
documents. I only want the code to select the embedded documents.

I have tried…..
ActiveSheet.Shapes.SelectAll

I have tried…..
ActiveSheet.OLEObjects.Select

I have tried…..
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = msoEmbeddedOLEObject Then
ActiveSheet.Shapes.SelectAll
End If
Next

But, they all select the buttons with the embedded documents. I only
want to select the embedded documents. Any help would be greatly
appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Select Embedded Documents

You usually have to use the Type or Name ProgID of the object. here is what
I usually do

Sub Test()
For Each obj In ActiveSheet.OLEObjects

Next obj
End Sub

Then right click obj and slect add to watch. As you step through the code
using F8 look at the obj in the watch and look at the parameters "Name" and
"Type". These will help you select the correct object.

Sub Test()
For Each obj In ActiveSheet.OLEObjects
If InStr(obj.progID, "Word") Then

End If
Next obj
End Sub

"Darrell Lankford" wrote:

Does anyone know a code that will select only the embedded documents
on a sheet? Im trying to setup a code that will copy and paste the
embedded documents to another sheet, but I cant figure out how to
keep the code from selecting all the other objects on the sheet. I
have Form Buttons, Option Buttons, & embedded PDF, Excel, or Word
documents. I only want the code to select the embedded documents.

I have tried€¦..
ActiveSheet.Shapes.SelectAll

I have tried€¦..
ActiveSheet.OLEObjects.Select

I have tried€¦..
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = msoEmbeddedOLEObject Then
ActiveSheet.Shapes.SelectAll
End If
Next

But, they all select the buttons with the embedded documents. I only
want to select the embedded documents. Any help would be greatly
appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Select Embedded Documents

Sub AllEmbededOLEcopy()
Dim i As Long, cnt As Long
Dim ole As OLEObject

With ActiveSheet.OLEObjects
If .Count Then
ReDim arr(1 To .Count)
For i = 1 To .Count
If .Item(i).OLEType = xlOLEEmbed Then
cnt = cnt + 1
arr(cnt) = i
End If
Next
If cnt < i Then
ReDim Preserve arr(1 To cnt)
End If
End If
End With

If cnt Then
' the select stuff only to help reposition in same place
Range("A1").Select
ActiveSheet.OLEObjects(arr).Copy
Worksheets(2).Activate ' the destination sheet
Range("A1").Select
ActiveSheet.Paste
Range("A1").Select
End If

'Application.ScreenUpdating = True
End Sub

Regards,
Peter T



"Darrell Lankford" wrote in message
...
Does anyone know a code that will select only the embedded documents
on a sheet? I’m trying to setup a code that will copy and paste the
embedded documents to another sheet, but I can’t figure out how to
keep the code from selecting all the other objects on the sheet. I
have Form Buttons, Option Buttons, & embedded PDF, Excel, or Word
documents. I only want the code to select the embedded documents.

I have tried…..
ActiveSheet.Shapes.SelectAll

I have tried…..
ActiveSheet.OLEObjects.Select

I have tried…..
Dim shp As Shape
For Each shp In ActiveSheet.Shapes
If shp.Type = msoEmbeddedOLEObject Then
ActiveSheet.Shapes.SelectAll
End If
Next

But, they all select the buttons with the embedded documents. I only
want to select the embedded documents. Any help would be greatly
appreciated.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Select Embedded Documents

I used Joel's code with a (MsgBox obj.progID) line and that told me
the type of each object.

Pete's code picked the objects that were just the PDF, Word, & Excel
embedded documents and not the buttons. Just what I need.

I thank both you guys for taking the time to help.
Darrell
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
Sorting a worksheet with embedded documents in one column JHQ Excel Discussion (Misc queries) 2 October 21st 08 05:45 PM
embedded documents in excel bothan25 Excel Discussion (Misc queries) 0 February 8th 08 12:54 AM
embedded Excel sheets in Word documents uatuma Excel Programming 2 January 1st 08 01:53 AM
Coping Embedded documents to local drive... CrosbyKim Excel Discussion (Misc queries) 1 December 4th 07 12:51 AM
Printing multiple embedded Word Documents [email protected] Excel Programming 7 November 17th 07 12:58 AM


All times are GMT +1. The time now is 11:53 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"