Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 30th, 2012, 04:45 AM
Registered User
 
Join Date: Oct 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chnage embedded images to filename/url

Hi - this is my first post on the board but I couldnt find the answer anywhere so thought I would try a post.

I have 4000+ survey responses and many of the rows have a photo of the respondent (optional). I need to extract these embedded images and put them online so I can access them as a url.

I have a simple row of data and at column H (optionally) has an embedded image. I want to be able to:
a) export that image to a folder
b) insert the filename for the above image to column I?

I have found some VBA code on this board (here) that provided a similar solution for exporting images as the background of a cell... However, I cannot follow the logic and I cant help but think there may be a simpler way of doing this... (code posted below).

Thanks for any advice or tips on creating a simpler function for this.

I am using Excel 2007 on a windows 7 home OS.

Code:
Public Sub Export()

        Dim objTemp As Object
        Dim objHolder As ChartObject
        Dim sngWidth As Integer
        Dim sngHeight As Integer
        Dim TheFilename
On Error GoTo skip


TheFilename = Cells(3, 11).Value

   'sets the picture as a temp object 
Set objTemp = ActiveSheet.Shapes(2)

ActiveSheet.Shapes(2).Select

    Selection.ShapeRange.ScaleHeight 1#, msoTrue, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleWidth 1#, msoTrue, msoScaleFromTopLeft
    sngWidth = objTemp.Width
    sngHeight = objTemp.Height


 Charts.Add
            ActiveChart.Location Where:=xlLocationAsObject, Name:=SheetNo
            Set objHolder = ThisWorkbook.Worksheets("Sheet1").ChartObjects(1)


With objHolder


                    .Width = sngWidth + 20
                    .Height = sngHeight + 20
                    objTemp.Copy
                End With


 With objHolder

                .Chart.Paste
                With .Chart.Shapes(1)
                    .Placement = xlMove
                    .Left = -4
                    .Top = -4
                End With
                .Width = sngWidth
                .Height = sngHeight
                .Chart.Export Filename:="C:\Photos\" & TheFilename & ".jpg", FilterName:="JPG"
                .Chart.Shapes(1).Delete

            End With
skip:



End Sub





Similar Threads
Thread Thread Starter Forum Replies Last Post
Images by filename ekugler Reporting Services 2 October 11th, 2007 04:21 AM
how do i remove the page/filename from my URL? panuvin ASP.NET 2.0 Basics 2 September 21st, 2007 09:12 AM
how to display images embedded in a database . jia ASP.NET 1.0 and 1.1 Basics 2 August 1st, 2007 03:58 PM
Getting images embedded in Word aniket123 Word VBA 0 February 27th, 2006 06:24 AM
how do I strip a URL down to the filename? mikehsu317 VBScript 1 July 3rd, 2005 02:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.