Results 1 to 6 of 6

Thread: Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

  1. #1

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    32

    Lightbulb Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

    v1.0.7.zip


    take care, this code use a conditionnal argument "DevMode", soo remove it (and unwanted references) when reuse it...

    Most of the intelligent code comme from :
    Extracting the embedded object from embedded files which are stored as structured storage files.
    Author : Microsoft Corporation
    Link : http://www.getcodesamples.com/src/30730C93/E11E84E8

    StgOpenStorage, Stream etc...
    ' Author : Eduardo Morcillo (Edanmo)
    ' Link : 'http://www.mvps.org/emorcillo/en/code/vb6/index.shtml

    Late binding of Shell32/NameSpace solution
    Author : Dirk Goldgar

    Editing elements in an OpenXML file using VBA
    Author : JKP Application Development Services
    http://www.jkp-ads.com/articles/Exce...leFormat02.asp

    it's not heavly tested, it's more a brain stoorming...insomnia occupation, but may be it's could help somebody ? not sure of that ....

    Test avec succes with Office 2010 32x fr Under XP 32x us, Windows 7 64x fr, Windows 8.1 64x fr and Windows 10 64x fr

    Update 1.0.5 correction of careless mistake
    Update 1.0.6 Late binding bug corrected (thank to Dirk Goldgar), and add more Error Handler's code
    Update 1.0.7 Fix internationalisation bug, and add new module to deal with ActiveX references dynamically
    Last edited by Thierry76; Nov 22nd, 2015 at 01:35 PM. Reason: careless mistake

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

    NB I still got problem with CreateObjet and Shell32.Shell and late binding... if some one could give me a clue
    what part?
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    32

    Re: Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

    Thanks westconn1 for your two words ...

    I will explain a little more my past problem and give you the solution...
    My code use a conditional params called "DevMode". It can be egale to 1 or 0... and I use it to easly code (I am a lasy codder)...
    When I turn it on (=1), I use references to all the ActiveX need, so I got intelligentsens, error handling, object explorer and so one...
    When I turn it off (=0), I remove as much references I can, to make my code more portable...

    The problem occure when DevMode=0, my code use at this time Late Binding ... and the above code alway fail :
    Set oShellApp = VBA.Interaction.CreateObject("Shell.Application")
    Set oZipFile = oShellApp.NameSpace(pZipFullname)

    oShellApp is ok, but oZipFile is alway nothing...

    If I turn DevMode=1, and add the reference to 'Microsoft Shell Controls And Automation', every things work again !!!!

    I found the clue in an other forum, the paranthesis sould be double.... like this
    Set oZipFile = oShellApp.NameSpace((pZipFullname))

    NB I use 'Shell32.Shell' (aka 'Microsoft Shell Controls And Automation') to unzip office files to avoid the need of extra component...
    Last edited by Thierry76; Nov 22nd, 2015 at 07:41 AM.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

    i have never had a problem using latebinding with shell.application
    this is tested and works correctly
    Code:
    Dim fn As String
    fn = "c:\temp\test1.zip"
    Set sh = CreateObject("shell.application")
    Set zip = sh.namespace(CVar(fn))
    note that using a string variable will fail (without error), a variant or literal string should not need converting

    i have no idea why the string variable is implicitly converted when using early binding, but can confirm this is the case
    shell specifies a variant argument
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  5. #5

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    32

    Re: Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

    Great ! This work .... It's may be the first time I like variant (don't ask me why, it's to long to explain, but usually try to never use then... I hate variant)
    Thanks westconn1

    I like it olso because it's simply my code... and at this time I was working on a major update : remove the tlb's reference ... I love this idea but it's hard code and make the code soo much complicated, so your improvement is wellcome...
    About removing tlb's references I found an example from a great guru Lavope in the forum next door.
    http://www.vbforums.com/showthread.p...s-without-TLBs

    NB The other goal I wanted to achive is so much easier, is to propose to extract one, some or all OLEObject(s)
    Last edited by Thierry76; Nov 24th, 2015 at 01:30 PM.

  6. #6

    Thread Starter
    Member
    Join Date
    Apr 2014
    Posts
    32

    Re: Extract OLEObjects for Word, Excel, PowerPoint file in Office2010

    New Version 1.0.11

    v1.0.11.zip


    No dependency, and all in a one class...

    it's work well, but code, and error handling is far from what I like...


    Call COM interfaces by pointer
    ' Author : Lavolpe (and some part from Olaf Schmidt)
    ' Link : http://www.vbforums.com/showthread.p...all-DLL-Calls)

    PS Including westconn1 advice
    Last edited by Thierry76; Dec 5th, 2015 at 11:23 AM.

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width