+ Reply to Thread
Results 1 to 4 of 4

Get PNG height and width

Hybrid View

  1. #1
    Registered User
    Join Date
    01-28-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    32

    Get PNG height and width

    Hi expert,

    For other image format, i can use below to get the Height and Width

    Set p = LoadPicture(imagefile)
    PicHt = p.Height
    PicWid = p.Width

    But loadpicture not support PNG file format, is that any other method to do so?

  2. #2
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Get PNG height and width

    Hi Chocobo,

    The following code works for me to insert a .PNG file into a spreadsheet:
    Sub ImportPngFile()
    
        Dim vntFilename As Variant
        Dim p As Object
        
        vntFilename = Application.GetOpenFilename("Images (*.png),*.png")
        If vntFilename = "False" Then Exit Sub
        
        Range("B11").Select 'Top and Left at Cell 'B11' Top Left Corner
        Set p = ActiveSheet.Pictures.Insert(vntFilename)
        Debug.Print p.Top
        Debug.Print p.Left
        Debug.Print p.Height
        Debug.Print p.Width
    
    End Sub
    Lewis
    Last edited by LJMetzger; 08-31-2015 at 10:02 AM.

  3. #3
    Registered User
    Join Date
    01-28-2015
    Location
    Hong Kong
    MS-Off Ver
    2013
    Posts
    32

    Re: Get PNG height and width

    Hi Lewis,

    Thanks for help, actually I tried to use Picture.Insert before, but seems this is only insert the link to excel but not the actual image....

  4. #4
    Forum Expert
    Join Date
    01-23-2013
    Location
    USA
    MS-Off Ver
    Microsoft 365 aka Office 365
    Posts
    3,863

    Re: Get PNG height and width

    After inserting, I changed the name of the .png file, closed Excel, and opened the file again. The image seems to be a permanent part of my Excel file using Excel 2003.

    When I remove the image from the Excel file, the Excel file size decreases by the size of the .png file.

    Lewis

+ 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. Replies: 3
    Last Post: 03-22-2013, 12:19 AM
  2. Set height and width of cells
    By copleyr in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-31-2009, 08:16 PM
  3. charting using height AND width
    By heski in forum Excel General
    Replies: 2
    Last Post: 10-12-2006, 08:53 PM
  4. [SOLVED] cell 's width and height
    By EXCEL NEWS in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-01-2006, 05:50 AM
  5. [SOLVED] Name Box Width and Height
    By Werner Rohrmoser in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-28-2006, 08:20 AM
  6. [SOLVED] Row height/column width
    By Connie Martin in forum Excel General
    Replies: 1
    Last Post: 03-20-2006, 12:55 PM
  7. Column Width and Row Height
    By Pillow in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 12-13-2005, 12:00 PM
  8. [SOLVED] Height/Width measurements
    By MrBill in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-18-2005, 07:06 PM

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