Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to insert a object in excel

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!!!

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default 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!!!

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to insert a object in excel

Hi Joel,

Sub InsertObject2()

MyFileName = Application.GetOpenFilename("")

ActiveSheet.Range("h15").Activate

ActiveSheet.OLEObjects.Add(Filename:=MyFileName, Link:=True, _
DisplayAsIcon:=True,
IconFileName:="C:\WINNT\Installer\{AC76BA86-7AD7-1033-7B44-A70000000000}\PDFFile.ico", _
IconIndex:=0, IconLabel:=MyFileName).Select

End Sub

"Joel" wrote:

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!!!

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 9,101
Default Macro to insert a object in excel

Lester: Do you need additional help. All you sent was updted code with no
comments.

"Lester from AUS" wrote:

Hi Joel,

Sub InsertObject2()

MyFileName = Application.GetOpenFilename("")

ActiveSheet.Range("h15").Activate

ActiveSheet.OLEObjects.Add(Filename:=MyFileName, Link:=True, _
DisplayAsIcon:=True,
IconFileName:="C:\WINNT\Installer\{AC76BA86-7AD7-1033-7B44-A70000000000}\PDFFile.ico", _
IconIndex:=0, IconLabel:=MyFileName).Select

End Sub

"Joel" wrote:

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!!!

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to insert a object in excel

Joel,

Sorry mate must have deleted the comments by error. The sub worked
perfectly, thanks a lot for your help. I just wanted to let you know that I
needed to make some slight changes as noted in the sub I sent. Basically, I
changed the Link to True and defined a location to attach the file. This now
works for All Files.

Thanks again Joel, you are a champ!!!


"Joel" wrote:

Lester: Do you need additional help. All you sent was updted code with no
comments.

"Lester from AUS" wrote:

Hi Joel,

Sub InsertObject2()

MyFileName = Application.GetOpenFilename("")

ActiveSheet.Range("h15").Activate

ActiveSheet.OLEObjects.Add(Filename:=MyFileName, Link:=True, _
DisplayAsIcon:=True,
IconFileName:="C:\WINNT\Installer\{AC76BA86-7AD7-1033-7B44-A70000000000}\PDFFile.ico", _
IconIndex:=0, IconLabel:=MyFileName).Select

End Sub

"Joel" wrote:

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!!!



  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 6
Default Macro to insert a object in excel

Joel,

Sorry mate I still need your help. When I use link=True, the file can not be
opened once emailed. You mentioned that your sub works for PDF files, but it
actually does not. It works for all other files (Excel, word, outlook) but
not PDF. Is this because the setting in my computer? I have tried changing
the IconFileName:=, but still can not get it working for PDF.

Any help would be much appreciated€¦

Many thanks


"Lester from AUS" wrote:

Joel,

Sorry mate must have deleted the comments by error. The sub worked
perfectly, thanks a lot for your help. I just wanted to let you know that I
needed to make some slight changes as noted in the sub I sent. Basically, I
changed the Link to True and defined a location to attach the file. This now
works for All Files.

Thanks again Joel, you are a champ!!!


"Joel" wrote:

Lester: Do you need additional help. All you sent was updted code with no
comments.

"Lester from AUS" wrote:

Hi Joel,

Sub InsertObject2()

MyFileName = Application.GetOpenFilename("")

ActiveSheet.Range("h15").Activate

ActiveSheet.OLEObjects.Add(Filename:=MyFileName, Link:=True, _
DisplayAsIcon:=True,
IconFileName:="C:\WINNT\Installer\{AC76BA86-7AD7-1033-7B44-A70000000000}\PDFFile.ico", _
IconIndex:=0, IconLabel:=MyFileName).Select

End Sub

"Joel" wrote:

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!!!

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
Insert large excel object into word BIZBRKR Excel Discussion (Misc queries) 2 January 7th 07 03:46 PM
How do i insert an outlook msg file object in excel Shefali Excel Worksheet Functions 0 September 7th 06 11:05 AM
Insert Object Don Excel Discussion (Misc queries) 0 August 16th 06 06:39 PM
How do I insert a 2-3 page Excel spreadsheet as an object in MS Wo D at Spectra Excel Discussion (Misc queries) 0 May 15th 06 07:39 PM
Create .NET object written in C# in Excel Macro Tom Chau Excel Discussion (Misc queries) 0 April 11th 06 07:38 AM


All times are GMT +1. The time now is 09:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"