Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Icon Type and Name when Insert File As Icon

Hello,
I'm using the following code to assist users in inserting files into the
Excel worksheet. It works fine, except that:

1. It shows the entire path - I'd like to see just the file name
2. It shows the Excel icon, even if it's a Word file. I know that it's
because that is written in the code and know I can specify Word, etc., but
can I change that so that the correct icon is displayed

Thanks.

ActiveSheet.Unprotect

'INSERT.OBJECT?(object_class, file_name, link_logical,
' display_icon_logical, icon_file, icon_number, icon_label)
ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"

ActiveSheet.Protect

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Icon Type and Name when Insert File As Icon

This is virtually as-is from the macro recorder

Insert, Object, Create from File,
tick Display as object
Browse

Sub Macro1()

ActiveSheet.Range("B2").Activate

Call ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Documents and Settings\Owner\My Documents\myWord.doc", _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:= _
"C:\WINDOWS\Installer\{90110409-6000-11D3-8CFE-0150048383C9}\wordicon.exe",
_
IconIndex:=0, _
IconLabel:= _
"C:\Documents and Settings\Owner\My Documents\myWord.doc")
End Sub

Regards,
Peter T


"Joyce" wrote in message
...
Hello,
I'm using the following code to assist users in inserting files into the
Excel worksheet. It works fine, except that:

1. It shows the entire path - I'd like to see just the file name
2. It shows the Excel icon, even if it's a Word file. I know that it's
because that is written in the code and know I can specify Word, etc., but
can I change that so that the correct icon is displayed

Thanks.

ActiveSheet.Unprotect

'INSERT.OBJECT?(object_class, file_name, link_logical,
' display_icon_logical, icon_file, icon_number, icon_label)
ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"

ActiveSheet.Protect



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Icon Type and Name when Insert File As Icon

That doesn't seem to work.

I really like the code that I posted earlier, because it opens into a clean
dialog box and is super easy for the users.

I just can't seem to get the icon to be whatever the document that is
attached is related to.

So, I would like a Word icon when it's a Word doc, an Excel icon if an Excel
doc, etc.

Thanks.

"Peter T" wrote:

This is virtually as-is from the macro recorder

Insert, Object, Create from File,
tick Display as object
Browse

Sub Macro1()

ActiveSheet.Range("B2").Activate

Call ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Documents and Settings\Owner\My Documents\myWord.doc", _
Link:=False, _
DisplayAsIcon:=True, _
IconFileName:= _
"C:\WINDOWS\Installer\{90110409-6000-11D3-8CFE-0150048383C9}\wordicon.exe",
_
IconIndex:=0, _
IconLabel:= _
"C:\Documents and Settings\Owner\My Documents\myWord.doc")
End Sub

Regards,
Peter T


"Joyce" wrote in message
...
Hello,
I'm using the following code to assist users in inserting files into the
Excel worksheet. It works fine, except that:

1. It shows the entire path - I'd like to see just the file name
2. It shows the Excel icon, even if it's a Word file. I know that it's
because that is written in the code and know I can specify Word, etc., but
can I change that so that the correct icon is displayed

Thanks.

ActiveSheet.Unprotect

'INSERT.OBJECT?(object_class, file_name, link_logical,
' display_icon_logical, icon_file, icon_number, icon_label)
ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"

ActiveSheet.Protect




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 option icon cvgairport Excel Discussion (Misc queries) 2 June 1st 10 02:31 PM
Icon Sets - Display icon in one cell depending upon value in anoth Nolene Excel Worksheet Functions 2 February 26th 10 05:43 AM
insert an ICON in a cell Uwe Excel Programming 4 September 28th 07 08:42 PM
Conditional Formatting icon change type problem Stephen Plotnick Excel Programming 1 May 24th 07 09:44 PM
'Insert Rows Icon' ginger Excel Discussion (Misc queries) 1 June 8th 06 01:57 AM


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