Insert obect

N

Naz

Hi

I'm trying to create a button that replicates Insert>Object, then from file
as icon.
I've tried recording the action but it either record nothing if i choose no
file, or the test file location but then i can figure out how to make sort of
prompt? Does anyone know who to do this?

All help is appreciated
 
J

Joel

You can open a dailog method like below

dlgAnswer = Application.Dialogs(xlDialogOpen).Show
 
J

Joel

Try this

Sub Uploader()

filetoOpen = Application _
.GetOpenFilename("Excel Files (*.xls), *.xls")
If filetoOpen = False Then
MsgBox "Cannot Open file - Exiting Macro"
Exit Sub
End If

Set newobj = ActiveSheet.OLEObjects.Add( _
Filename:=filetoOpen, _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:= _

"C:\WINDOWS\Installer\{90110409-6000-11D3-8CFE-0150048383C9}\xlicons.exe", _
IconIndex:=0, _
IconLabel:=filetoOpen)
End Sub
 
N

Naz

Hi Joel thanks

But where would i put that line in the code

Sub Uploader()

Workbooks.Open Filename:="C:\Book1.xls"
ActiveWindow.Visible = False
ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Book1.xls", Link:=False, _
DisplayAsIcon:=True, IconFileName:= _

"C:\WINDOWS\Installer\{90110409-6000-11D3-8CFE-0150048383C9}\xlicons.exe", _
IconIndex:=0, IconLabel:="C:\Book1.xls" _
).Select

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top