Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello all,
I have, unfortunately, entered the realm of VBA limbo, where I understand how code works by reading it, but have no idea how to write it (having just picked things up over time). What I am trying to do is add functionality into my workbook where a user can click a button to insert an object, much like you would do via the Insert -- Object menu option. My current thought was to use Jim Rech's 'Browse for Folder' in combination with a simple recorded Macro. Basically, the user should click the button, be prompted with an ability to select the file to insert, and then have that location of the file be returned back to the VBA code so that it can go ahead and insert it. I can work the macro's independently - Jim's will browse for a file, but only returns a msgbox. My simple recorded macro will insert an object fine, but only from a static - hardcoded filename. I'd obviously like to replace the embedded filename with the prompting from Jim's code so that rather than return a msgbox, it returns the filename to my own macro and voila, object inserted. If there is a better method I am very open to it. Thanks! Jim's BrowseForFolder (minus all the background info obviously): Sub BrowseFolders() Dim RetStr As String, Flags As Long, DoCenter As Boolean Flags = BIF_RETURNONLYFSDIRS + BIF_BROWSEINCLUDEFILES + BIF_NEWDIALOGSTYLE With Sheet1 DoCenter = True End With RetStr = GetDirectory(CurDir, Flags, DoCenter, "Please select a location to store data files") If RetStr < "" Then MsgBox RetStr End Sub My easy recorded Macro, would like to replace the "c:\...." with what comes from Jim's, but can't figure it out: Sub InsertObject() ActiveSheet.OLEObjects.Add(Filename:= _ "c:\files\file.abc", Link:=True, _ DisplayAsIcon:=True, IconFileName:= _ "C:\WINDOWS\Installer \{90110409-6000-11D3-8CFE-0150048383C9}\xlicons.exe", _ IconIndex:=0, IconLabel:= _ "c:\files\file.abc").Select End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
turn on insert comments ability in Excel | Excel Discussion (Misc queries) | |||
Macro to insert a object in excel | Excel Discussion (Misc queries) | |||
Macro to insert object into spreadsheet ?? | Excel Programming | |||
Browsing/opening a file with a macro | Excel Discussion (Misc queries) | |||
Excel needs to have the ability to insert "SUB" worksheets | Excel Worksheet Functions |