+ Reply to Thread
Results 1 to 5 of 5

Check if Object is embedded in Excel

  1. #1
    Registered User
    Join Date
    02-04-2019
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    41

    Check if Object is embedded in Excel

    Hi all,

    I have a requirement to check if an object (can be any format -.docx, .pdf, etc) has been embedded to a spreadsheet.
    The code I have will embed the file to cell P7 as the location.

    There is a 'Check Document' Sub that checks if certain criteria have been completed (e.g. specific cells) in the spreadsheet before uploading to our SharePoint, if not all criteria is satisfied, it will exit the Sub and not post to SP, with a message box advising the user what is missing.
    The code I use to check if cells are populated or not is (should noted that there is another bit of code to create the message box):

    Please Login or Register  to view this content.
    I have searched these forums and google but haven't been able to determine how (or if its possible) to check if a file is embedded at cell P7.

    2 Questions

    1st - How can I check if a file (Object) is located in cell P7?
    2nd - Can I amend the above code to so that it will exit the sub if an object is not in the nominated cell?

    Hoping someone can help me with this.
    Thank you in advance,
    Chris

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Check if Object is embedded in Excel

    Hi,

    Is the file likely to be so small you can't see it?

    One way would be

    Please Login or Register  to view this content.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    02-04-2019
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Check if Object is embedded in Excel

    Hi Richard,

    Thank you for your reply.

    The icon size isn't the problem, if embedded, it is visible.

    AML.jpg

    it's more adding the object/shape check to the existing automation of checking completed worksheet cell criteria (~20 cells checked), when clicking a 'Submit' macro button - with the following outcomes:
    - If all criteria is satisfied, then the 'Submit' SUB will save the Excel file to our SharePoint.
    - If all criteria is not satisfied, then exit the 'Submit' SUB and gives a message box alert to the user to fill in the missing info. (to clarify, the embedded object not being in P7 does not meet criteria)

    If I am understanding your suggested code, it will provide a message box if there is a Object embedded in P7.
    I would like to include, with the other mandatory field checks, and exit the Submit Sub if not present but proceed if the Object/Shape is present in P7.

    Apologies if this is a bit confusing

    I tried to amend your code and integrate it into mine, but it doesn't return an error or add a line in the msgbox, when there is no file embedded (with Shp defined as Shape).

    Please Login or Register  to view this content.
    thanks,
    Chris
    Last edited by ChrisMP; 08-03-2022 at 09:08 AM.

  4. #4
    Forum Expert
    Join Date
    08-17-2007
    Location
    Poland
    Posts
    2,224

    Re: Check if Object is embedded in Excel

    One problem with identifying objects embedded in a sheet is that the OLEObject is not associated with a specific cell. Scenario: for example, using a macro, an object is embedded in cell P7 (more precisely, the upper-left corner of the object is in cell P7). An unruly user moved the object (top left corner) to cell P6 (by 1-2 pixels at most). Searching the addresses of the "source" cells with the macro, we are not able to check whether the required object has been added to the sheet. We see that it is there, while the macro "does not see".
    There are at least two solutions to this problem. Both require giving a proper name to the embedded object.
    1 Either the name of the object will contain the address of the cell with which we will bind it. Then, by searching OLE objects, we can see if the object has been associated with a specific cell. Example of the name P7_Object1 or E178_Object2
    2. or we give each OLE object a specific (unique) name, e.g. CreditAppForm, AMLForm, VATCert, VATExCert, etc. Then we check that the sheet has all the objects with the required names.

    Assuming that the first form of object naming was chosen, the macro to check for the presence of OLE objects could look like this:
    Please Login or Register  to view this content.
    You should also add a line of code in the macros that insert an OLE object into the sheet, which will appropriately name each of the inserted objects.

    Artik

  5. #5
    Registered User
    Join Date
    02-04-2019
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    41

    Re: Check if Object is embedded in Excel

    Thank you Artik, very much appreciate the time taken to reply and to explain,
    I will play around and see if I can get this to work.

    Again, thank you very much.
    Chris

+ 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. Embedded word object in excel as TEXT
    By chaohung1115 in forum Excel General
    Replies: 0
    Last Post: 10-13-2019, 12:38 PM
  2. [SOLVED] Embedded Excel Object - Updating Formulas
    By bradlehoux in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-02-2018, 04:11 PM
  3. Excel Object embedded in PPT resizes
    By SUPPO_USN in forum Excel General
    Replies: 1
    Last Post: 06-02-2017, 09:49 AM
  4. Macro to access embedded excel object
    By SUPPO_USN in forum PowerPoint Formatting & General
    Replies: 1
    Last Post: 04-27-2017, 09:19 AM
  5. Help with VBA Excel Range to Embedded Word Object
    By cuchulainem in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-28-2013, 04:53 PM
  6. set calculation property in embedded excel object
    By erickd in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 11-17-2010, 03:55 PM
  7. Embedded Excel Object - Containers Path and Name
    By GerryO in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-21-2006, 10:40 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