+ Reply to Thread
Results 1 to 6 of 6

Standard size while inserting pictures with VBA/macro

  1. #1
    Registered User
    Join Date
    11-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    4

    Standard size while inserting pictures with VBA/macro

    Hey guys,

    I've got a VBA/maco for auto placing the picture with the standard size:

    Height: 1,27 cm
    Width: 1,69 cm


    The VBA I use is:

    Please Login or Register  to view this content.


    But now I want the following size for all pictures:

    Height: 1,1 cm
    Width: 3,38 cm



    How can I implement that in the code?
    Last edited by JBeaucaire; 11-30-2012 at 09:01 PM. Reason: Added code tags, as per forum rules. Don't forget!

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Standard size while inserting pictures with VBA/macro

    I'm not sure if you're asking how to change your code to insert the pictures with the specified size, in which case change the .height and .width lines to:
    Please Login or Register  to view this content.
    Or how to resize the existing pictures, in which case run:
    Please Login or Register  to view this content.
    Post responsibly. Search for excelforum.com

  3. #3
    Registered User
    Join Date
    11-08-2012
    Location
    Nagpur, India
    MS-Off Ver
    Excel 2003
    Posts
    3

    Re: Standard size while inserting pictures with VBA/macro

    great work man this is what i was searching for.....however I want to add multipul pics one below another.....how do i do that???

  4. #4
    Registered User
    Join Date
    11-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Standard size while inserting pictures with VBA/macro

    Sub test()
    Dim myFiles, e
    myFiles = Application.GetOpenFilename(, , , , True)
    If Not IsArray(myFiles) Then Exit Sub
    For Each e In myFiles
    With ActiveSheet
    With .Pictures.Insert(e)
    .Left = Range("b1").Left + 289
    .Top = Range("b1").Top + 100
    .Height = Application.CentimetersToPoints(1.1)
    .Width = Application.CentimetersToPoints(3.38)
    End With
    End With
    Next
    End Sub


    So it should be like this? When I use this code, it still gives other sizes to picture. Example, I uploaded a picture with size 627 x 407, and when I insert that picture
    into Excel using the VBA above I get the size:

    Height: 2.19
    Width: 3.38

    which means that he does resize the width properly, but not the height.

  5. #5
    Registered User
    Join Date
    11-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Standard size while inserting pictures with VBA/macro

    Oh might have found the problem.

    The Aspect Ratio is probably locked..

    Could someone post here the complete code including 'unlock aspect ratio'?

  6. #6
    Registered User
    Join Date
    11-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Standard size while inserting pictures with VBA/macro

    Anyone who could help me implement that unlock aspect ratio if that is the solution? Because my boss would really like to start his administration

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

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