Consulting

Results 1 to 6 of 6

Thread: Change ActiveX Image Control from UserForm

  1. #1
    VBAX Regular
    Joined
    Feb 2015
    Posts
    81
    Location

    Change ActiveX Image Control from UserForm

    Good morning VBA Masters,

    I am currently working on a process that opens a PowerPointPresentation, copies and saves the slides as a jpg then opens a Word Documentand changes the .Picture property of the ActiveX Image Control, of which thereare 17.

    The code I have opens the PowerPoint, copies and saves theslides correctly, then opens the Word document and then I receive a Run-timeerror, Method ‘Picture’ of object ‘Image’ failed.

    Currently I am just trying to get one picture to change,with no success.

    Below is the code that I currently have and attached are examplesof the Excel and Word files I am using.
    Sub Imp_Res_Grphs()
        Dim pptApp AsObject
        Dim pptFile AsString
        Dim pptPres AsObject
        Dim wrdApp AsObject
        Dim wrdFile AsObject
       pptFile ="C:\Users\Chunk\Reports\str1_totals.pptx"
        Set pptApp =CreateObject("PowerPoint.Application")
    pptApp.Visible = True
     Set pptPres =pptApp.Presentations.Open(pptFile)
    'Exports slides from Powerpoint and saves as jpg file
        With pptPres
            .Slides(2).Export"C:\Users\Chunk\Reports\Slides\" &"all_stores_ttl.jpg", "JPG"
           .Slides(3).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depa.jpg", "JPG"
           .Slides(4).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depb.jpg", "JPG"
           .Slides(5).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depc.jpg", "JPG"
           .Slides(6).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depd.jpg", "JPG"
           .Slides(7).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depe.jpg", "JPG"
           .Slides(8).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depf.jpg", "JPG"
           .Slides(9).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depg.jpg", "JPG"
           .Slides(10).Export "C:\Users\Chunk\Reports\Slides\" &"str1_deph.jpg", "JPG"
           .Slides(11).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depi.jpg", "JPG"
           .Slides(12).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depk.jpg", "JPG"
           .Slides(13).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depl.jpg", "JPG"
           .Slides(14).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depm.jpg", "JPG"
           .Slides(15).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depn.jpg", "JPG"
            .Slides(16).Export"C:\Users\Chunk\Reports\Slides\" & "str1_depo.jpg","JPG"
           .Slides(17).Export "C:\Users\Chunk\Reports\Slides\" &"str1_depp.jpg", "JPG"
           .Slides(18).Export "C:\Users\Chunk\Reports\Slides\" &"str1_ttl.jpg", "JPG"
    
        End With
    
        'closes powerpoint
        pptPres.Close
        Set pptPres =Nothing
        pptApp.Quit
        Set pptApp =Nothing
    
        'Open Worddocument and import graphs
        Set wrdApp =CreateObject("Word.Application")
        wrdApp.Visible =True
    
        Set wrdFile =wrdApp.Documents.Open("C:\Users\Chunk\Reports\Store1_Weekly_Report.docm")
    
    
    
        With wrdFile
    .Image1.Picture =LoadPicture("C:\Users\Chunk\Reports\Slides\tot_prod.jpg")
    End With
    End Sub




    Any help/direction you can give is greatly appreciated.

    Sincerely,

    Chunk

    Attached Files Attached Files

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Open your DOCM and in Developer ribbon item, choose Design mode like you would in Excel. Doubleclick the object. You can then see the control's name.

    .img_stores_ttl.Picture = LoadPicture("C:\Users\Chunk\Reports\Slides\tot_prod.jpg")

  3. #3
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    I haven't got a clue what you are trying to accomplish.

    1. You don't need powerpoint to save shapes in Excel as a file
    2. You don't need Word to adapt properties of picture files

  4. #4
    VBAX Regular
    Joined
    Feb 2015
    Posts
    81
    Location
    snb,

    The short and dirty of it is this,

    I'm running a userform, from excel. I want to take the slides from a powerpoint file and insert them into a word document in a specific order.

    Chunk

  5. #5
    Knowledge Base Approver VBAX Wizard
    Joined
    Apr 2012
    Posts
    5,646
    Why Excel ?

    You can use a userform in Word or in Powerpoint

  6. #6
    VBAX Regular
    Joined
    Feb 2015
    Posts
    81
    Location
    snb,

    I am using excel because I already have a userform built that deals with like data for the report I am producing.

    Chunk

Posting Permissions

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