Embbed Object but format size VBA

ryan_law2000

Well-known Member
Joined
Oct 2, 2007
Messages
738
Hello Everyone I have VBA that embeds an object but I want to be able to set the size of it.
Any ideas how to change this from the size of a cell to actually enter in the values of size that I need?
I also want it to always display "FIELD TICKET" as the icon text but cant seem to make it work.
Thanks

Code:
Sub AttachTicket()
     Dim vFile As String
     Dim objI As Object
     Dim rngI As Range

     For Each rngI In Range("J17")    'make range any size, or use Selection for flexibility
         vFile = Application.GetOpenFilename("All Files,*.*", Title:="Find file to insert")
         If LCase(vFile) = "false" Then Exit Sub
         Set objI = ActiveSheet.OLEObjects.Add(Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconLabel:=vFile)
         objI.Left = rngI.Left
         objI.Top = rngI.Top
         objI.Height = rngI.Height
         objI.Width = rngI.Width
         'If objI.Height > rngI.Height Then
             'objI.Height = rngI.Height
         'End If
     Next rngI
      With Worksheets("Main").Range("K18")
        .Value = "<-- Attached! Double Click to View"
        End With
     
 End Sub
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
Code:
[COLOR=#333333]'If objI.Height > rngI.Height Then
[/COLOR]'objI.Height = rngI.Height [COLOR=#333333]         
'End If[/COLOR]
What you want is :

rngI.RowHeight=objI.Height
 
Last edited:
Upvote 0
I also want it to always display "FIELD TICKET" as the icon text but cant seem to make it work.

Try...

Code:
IconLabel:="FIELD TICKET"
 
Upvote 0

Forum statistics

Threads
1,214,954
Messages
6,122,461
Members
449,085
Latest member
ExcelError

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top