?
Solved

Use vb6 program to change size of image in an excel worksheet

Posted on 2012-03-09
2
Medium Priority
?
692 Views
Last Modified: 2012-03-10
I'm using the following code to insert an image into an Excel 2007 Worksheet utilizing VB6 (not a macro).

Const msoFalse = 1
Sub positionpicture()
Dim p As Picture
Dim wkb As Workbook
Dim wks As Worksheet
Dim pBeginX As Single 'relative to upper-left corner of document
Dim pBeginY As Single 'relative to upper-left corner of document
Dim pEndX As Single 'relative to upper-left corner of document
Dim pEndY As Single 'relative to upper-left corner of document
Dim InchToPoint As Single

    Set wkb = ActiveWorkbook
    Set wks = Sheets("Sheet1")
   
    '18 points per .25 inches
    InchToPoint = 18 / 0.25
   
    '2 inches from the left, 6 inches down
    pBeginX = 1 * InchToPoint
    pBeginY = 1 * InchToPoint
    pEndX = 11 * InchToPoint
    pEndY = 11 * InchToPoint
   
    Set p = wks.Pictures.Insert(App.Path & "\" & "tlsig.jpg")

    'keep or lock the aspect ratio
    p.ShapeRange.LockAspectRatio = msoFalse
    'Top left corner
    p.Locked = False
    p.Left = pBeginX
    p.Top = pBeginY
End Sub

How can I resize the image and position it? The image is not responding to the above attempt to position it nor is it responding to the following code:
p.left = wks.range("A39").left
p.top = wks.range("A39").top

Thanks.
0
Comment
Question by:tlengnick
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 

Accepted Solution

by:
tlengnick earned 0 total points
ID: 37705324
I got it:

Sub PositionPicture3()

Dim Excel_App As Excel.Application
Const msoFalse = 1

With Excel_App
  ActiveSheet.Shapes(ActiveSheet.Shapes.Count).Select

    With Selection
        .ShapeRange.LockAspectRatio = msoFalse
        .ShapeRange.Top = 660
        .ShapeRange.Left = 10
        .ShapeRange.Width = 200
        .Placement = xlMoveAndSize
    End With
End With
0
 

Author Closing Comment

by:tlengnick
ID: 37705327
Found the answer online... figured I'd add it to knowledgebase.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question