Macro to insert a object in excel
The code below works for pdf files. A got the basic code from a learn macro.
the location of the ICON may be different on your PC. don't know enough
about the subject. for a Text file it will display the pdf icon. It looks
like you may havve tto modify the program for each type file you want to add.
check the extension on the file and the use a diffferent ICON for each file
type.
Sub InsertObject()
MyFileName = Application.GetOpenFilename("")
CellLocation = InputBox("Enter Cell Location")
CellLocation = "" + CellLocation + ""
ActiveSheet.Range(CellLocation).Activate
ActiveSheet.OLEObjects.Add(Filename:=MyFileName, Link:=False, _
DisplayAsIcon:=True, IconFileName:= _
"C:\WINNT\Installer\{AC76BA86-7AD7-1033-7B44-A70000000000}\PDFFile.ico", _
IconIndex:=0, IconLabel:=MyFileName).Select
End Sub
"Lester from AUS" wrote:
Hello, I wonder if anyone can help. I am trying to create a Macro to insert
an object (any type of file .xls.jog.pdf.doc etc etc) in an excel workbook to
a specific location. I want the macro to perform the following excel command:
Select the location of the file to be inserted select €śInsert€ť from the menu
bar and then Object move to tab €śCreate from List€ť tick the box
€śdisplay as icon€ť and then allow the user to browse and select the file
they wish to insert. I also want to inserted file to be in a specific
location in the worksheet.
Thanks a million excellers!!!
|