Page 1 of 3 123 LastLast
Results 1 to 15 of 32
  1. #1
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  2. #2
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  3. #3
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  4. #4
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  5. #5
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  6. #6
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  7. #7
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  8. #8
    3 Star Lounger
    Join Date
    Jun 2009
    Location
    Hemet CA
    Posts
    310
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I知 using Excel 2007 and I知 trying to figure out if there is a way to insert a photo in a randomly selected cell and have both the photo and cell be re-sized the same using VBA
    Example below
    .Height = Application.InchesToPoints(1.5)
    .Width = Application.InchesToPoints(1.75)
    Currently I知 using code below to insert a photo into a pre sized cell, preselected cell.
    Using my present method takes up to much space if photos are not used, so what I知 trying to do is save open space on a sheet if areas are not used for photos
    Any possible suggestions
    Code:
    Dim sFile As Variant, r As Range
      Set r = Range("A1")
      
      sFile = Application.GetOpenFilename(FileFilter:="Pic Files (*.jpg;*.bmp), *.jpg;*.bmp", Title:="Browse to select a picture")
      If sFile = False Then Exit Sub
      ActiveSheet.Unprotect ""
      Dim i As Long
      For i = ActiveSheet.Pictures.Count To 1 Step -1
        If ActiveSheet.Pictures(i).Top = r.Top And _
            ActiveSheet.Pictures(i).Left = r.Left Then
          ActiveSheet.Pictures(i).Delete
        End If
      Next i
      With ActiveSheet.Pictures.Insert(sFile).ShapeRange
        .LockAspectRatio = True
        .Top = r.Top
        .Left = r.Left
        .Height = r.RowHeight * r.MergeArea.Rows.Count
      End With
      ActiveSheet.Protect ""

  9. #9
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  10. #10
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  11. #11
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  12. #12
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  13. #13
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  14. #14
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

  15. #15
    5 Star Lounger
    Join Date
    Aug 2001
    Location
    Surrey, United Kingdom
    Posts
    1,001
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Morning

    I was trying to do something similar in Excel 2003 and came across this article'Resize Image', I cannot claim to have done it with 100% accuracy because I am somewhat "code challenged". Maybe you could adapt the suggestion to suit for Excel 2007

    Editted: Amend Typo
    Cheers

    Steve

    Asking the questions everbody wants the answers too but feels too stupid to ask themselves :-)

Page 1 of 3 123 LastLast

Posting Permissions

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