+ Reply to Thread
Results 1 to 7 of 7

Insert file as OLEobject by referencing a cell

  1. #1
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Insert file as OLEobject by referencing a cell

    Hi. I've been banging my head against the wall for 3 hours and I can't figure this out.

    In F2 I have c:\example.txt
    In F3 I have c:\example2.txt

    I'm trying to insert the files in G2 and G3 respectively

    Please Login or Register  to view this content.
    I get runtime error 1004 cannot insert object. But if I use the following code it works fine

    Please Login or Register  to view this content.
    I have F2 and F3 formatted as text. Can someone help me figure out what's wrong?
    Thanks!!
    Dave

  2. #2
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Insert file as OLEobject by referencing a cell

    Hi -

    What error you got in the first one?

    event

  3. #3
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: Insert file as OLEobject by referencing a cell

    here's what i get when i try to call Filename:=fPath

    when i send fPath to a msgbox i can see that it's the correct path+filename+extension. the only thing I can think of is that for some reason VBA doesn't think fPath is a string

    error.JPG

  4. #4
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Insert file as OLEobject by referencing a cell

    Hi -

    I don't have 2013 for now so I could not test it, however, it does work in 2010

    event

  5. #5
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: Insert file as OLEobject by referencing a cell

    I must be doing something fundamentally wrong because I tried this code and it evaluated to "The file does not exist" even though the path and file in the msgbox is correct. And if I change ObjFso.FileExists(FolderPath) to ObjFso.FileExists("same string in the msgbox") it then evaluates to "The file exists". hmmm

    Please Login or Register  to view this content.

  6. #6
    Valued Forum Contributor
    Join Date
    11-15-2008
    Location
    ph
    MS-Off Ver
    2007/2010/2016
    Posts
    479

    Re: Insert file as OLEobject by referencing a cell

    Hi -

    Try to use the debug.print command to pull out the filename from the variable

    event

  7. #7
    Registered User
    Join Date
    06-20-2015
    Location
    US
    MS-Off Ver
    2013
    Posts
    11

    Re: Insert file as OLEobject by referencing a cell

    Hi all.

    Thanks again to everyone who's helped. I was able to combine the different advice from this thread as well as some other threads into VBA that:

    1) opens windows file viewer
    2) searches through the selected folder and lists the files and some of the properties for each file in the folder
    3) then changes the file names into hyperlinks
    4) then embeds the PNG, JPG and PDF files into the spreadsheet

    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Printing single sheet to .pdf then embedding the file. (renaming OLEObject?)
    By Canuckle777 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-14-2013, 12:56 PM
  2. Unable to add PDF file as OLEObject
    By eduque in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-14-2013, 09:44 PM
  3. [SOLVED] code to check if an oleobject already exists in the specified cell before adding a new one
    By Willardio in forum Excel Programming / VBA / Macros
    Replies: 22
    Last Post: 12-18-2012, 09:14 PM
  4. Referencing a Cell in another Excel File
    By Bokya in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 11-06-2012, 03:28 AM
  5. Macro to find text and insert an OLEObject at an offset
    By Willardio in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-28-2012, 04:44 PM
  6. VBA code to insert formula with automatic cell referencing & size
    By vbatech in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-27-2012, 04:32 AM
  7. How to Insert OLEObject via User Defined Formula
    By spetty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-19-2012, 10:50 AM
  8. Referencing Cell Info to call a File
    By stuckupnorth in forum Excel General
    Replies: 2
    Last Post: 07-07-2006, 10:48 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1