PC Review


Reply
Thread Tools Rate Thread

Code to Insert File as Icon & Open Browse Dialog Box

 
 
Joyce
Guest
Posts: n/a
 
      5th Oct 2009
Hi,

I am wondering if it's possible to get users of a file to the Browse dialog
box when inserting an object as an icon.

This gets me almost there...
ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"

Thank you.
 
Reply With Quote
 
 
 
 
Jacob Skaria
Guest
Posts: n/a
 
      5th Oct 2009
strFile = Application.GetOpenFilename

If this post helps click Yes
---------------
Jacob Skaria


"Joyce" wrote:

> Hi,
>
> I am wondering if it's possible to get users of a file to the Browse dialog
> box when inserting an object as an icon.
>
> This gets me almost there...
> ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"
>
> Thank you.

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      5th Oct 2009
'for the second part of the question

strFile = Application.GetOpenFilename
ActiveSheet.OLEObjects.Add Filename:=strFile, Link:=False, _
DisplayAsIcon:=True, IconFileName:=strIconFile, IconIndex:=0, _
IconLabel:=strFile

'Record a macro..and edit to suit...

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

> strFile = Application.GetOpenFilename
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Joyce" wrote:
>
> > Hi,
> >
> > I am wondering if it's possible to get users of a file to the Browse dialog
> > box when inserting an object as an icon.
> >
> > This gets me almost there...
> > ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"
> >
> > Thank you.

 
Reply With Quote
 
Joyce
Guest
Posts: n/a
 
      5th Oct 2009
Hello Jacob and thank you for your response.

It works beautifully. I'm wondering if there's anything I can add to do
either of the following:

1. Display only the file name and not the complete path.
2. Display the icon image of the software the file was created in (Adobe,
Word, Excel)

Thanks very much.

"Jacob Skaria" wrote:

> 'for the second part of the question
>
> strFile = Application.GetOpenFilename
> ActiveSheet.OLEObjects.Add Filename:=strFile, Link:=False, _
> DisplayAsIcon:=True, IconFileName:=strIconFile, IconIndex:=0, _
> IconLabel:=strFile
>
> 'Record a macro..and edit to suit...
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Jacob Skaria" wrote:
>
> > strFile = Application.GetOpenFilename
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Joyce" wrote:
> >
> > > Hi,
> > >
> > > I am wondering if it's possible to get users of a file to the Browse dialog
> > > box when inserting an object as an icon.
> > >
> > > This gets me almost there...
> > > ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"
> > >
> > > Thank you.

 
Reply With Quote
 
Jacob Skaria
Guest
Posts: n/a
 
      5th Oct 2009
Modified to display just the file name...For the icon try recording a macro
and copy paste the iconfilename from the recorded macro to the below code...

strFile = Application.GetOpenFilename
ActiveSheet.OLEObjects.Add Filename:=strFile, Link:=False, _
DisplayAsIcon:=True, IconFileName:=strIconFile, IconIndex:=0, _
IconLabel:=Mid(strFile, InStrRev(strFile, "\") + 1)

If this post helps click Yes
---------------
Jacob Skaria


"Joyce" wrote:

> Hello Jacob and thank you for your response.
>
> It works beautifully. I'm wondering if there's anything I can add to do
> either of the following:
>
> 1. Display only the file name and not the complete path.
> 2. Display the icon image of the software the file was created in (Adobe,
> Word, Excel)
>
> Thanks very much.
>
> "Jacob Skaria" wrote:
>
> > 'for the second part of the question
> >
> > strFile = Application.GetOpenFilename
> > ActiveSheet.OLEObjects.Add Filename:=strFile, Link:=False, _
> > DisplayAsIcon:=True, IconFileName:=strIconFile, IconIndex:=0, _
> > IconLabel:=strFile
> >
> > 'Record a macro..and edit to suit...
> >
> > If this post helps click Yes
> > ---------------
> > Jacob Skaria
> >
> >
> > "Jacob Skaria" wrote:
> >
> > > strFile = Application.GetOpenFilename
> > >
> > > If this post helps click Yes
> > > ---------------
> > > Jacob Skaria
> > >
> > >
> > > "Joyce" wrote:
> > >
> > > > Hi,
> > > >
> > > > I am wondering if it's possible to get users of a file to the Browse dialog
> > > > box when inserting an object as an icon.
> > > >
> > > > This gets me almost there...
> > > > ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"
> > > >
> > > > Thank you.

 
Reply With Quote
 
Joyce
Guest
Posts: n/a
 
      6th Oct 2009
Thanks Jacob. That worked beautifully.

There are two things I'm wondering now.

1. What if the file is pdf or another type of file - is there a select case
I could use?
2. What if the user's computer doesn't use the exact path to the icon file
as mine?

Thanks again for your help!


"Jacob Skaria" wrote:

> Modified to display just the file name...For the icon try recording a macro
> and copy paste the iconfilename from the recorded macro to the below code...
>
> strFile = Application.GetOpenFilename
> ActiveSheet.OLEObjects.Add Filename:=strFile, Link:=False, _
> DisplayAsIcon:=True, IconFileName:=strIconFile, IconIndex:=0, _
> IconLabel:=Mid(strFile, InStrRev(strFile, "\") + 1)
>
> If this post helps click Yes
> ---------------
> Jacob Skaria
>
>
> "Joyce" wrote:
>
> > Hello Jacob and thank you for your response.
> >
> > It works beautifully. I'm wondering if there's anything I can add to do
> > either of the following:
> >
> > 1. Display only the file name and not the complete path.
> > 2. Display the icon image of the software the file was created in (Adobe,
> > Word, Excel)
> >
> > Thanks very much.
> >
> > "Jacob Skaria" wrote:
> >
> > > 'for the second part of the question
> > >
> > > strFile = Application.GetOpenFilename
> > > ActiveSheet.OLEObjects.Add Filename:=strFile, Link:=False, _
> > > DisplayAsIcon:=True, IconFileName:=strIconFile, IconIndex:=0, _
> > > IconLabel:=strFile
> > >
> > > 'Record a macro..and edit to suit...
> > >
> > > If this post helps click Yes
> > > ---------------
> > > Jacob Skaria
> > >
> > >
> > > "Jacob Skaria" wrote:
> > >
> > > > strFile = Application.GetOpenFilename
> > > >
> > > > If this post helps click Yes
> > > > ---------------
> > > > Jacob Skaria
> > > >
> > > >
> > > > "Joyce" wrote:
> > > >
> > > > > Hi,
> > > > >
> > > > > I am wondering if it's possible to get users of a file to the Browse dialog
> > > > > box when inserting an object as an icon.
> > > > >
> > > > > This gets me almost there...
> > > > > ExecuteExcel4Macro "INSERT.OBJECT?(,""C:\"",False,True,)"
> > > > >
> > > > > Thank you.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA code to open the insert object and bring you to the browse point MartinR Microsoft Access 7 12th Jul 2006 01:24 PM
Code for bring up the file->open dialog box =?Utf-8?B?QmVu?= Microsoft Excel Programming 3 10th Feb 2006 03:21 AM
Code to skip transferspreadsheet if file open dialog box is cancel =?Utf-8?B?TWFCZWxs?= Microsoft Access External Data 1 22nd Oct 2004 09:18 PM
Code to open windows open/select file dialog window LisaB Microsoft Access VBA Modules 2 21st Oct 2003 02:33 PM
Open File/Browse Dialog VBA code Bryan Microsoft Access Form Coding 3 15th Oct 2003 08:26 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:05 PM.