N
Nat
Version: 2004
Hello
New to Excel 2004 - regular user of Excel 2007
I have a number of macros in a spreadhseet which were written for MS Excel 2007. They work fine on my pc.
One of the users of the spreadsheet is on a Mac using Excel 2004.
The following Excel 2007 macro (which inserts all jpg images contained in a folder in a directory into a worksheet - noting there will be a variable number of images each time the macro is run - hence reason they are not individually named) works fine in 2007 but does nothing in Excel 2004.
Suspect it has to do with my limited mac knowledge - especially about naming conventions and/or the use of the wildcard. Or maybe the file extension (something other than jpg perhaps). Yep, struggling to know what!!!
Any advice, or code which will work (i.e grab all images from a folder, insert them into one worksheet and then ensure all the same size)would be greatly appreciated.
The location of the jpgs on the Mac is Macintosh HD:Users:Rocuments:Atlashotos
Here is the 2007 code
Sub InsertPix()
'Inserts all pictures from selected directory on top of each other in worksheet.
Dim MyPath As String
Dim FName As String
MyPath = "C:\Users\Nat\Templates\"
FName = Dir(MyPath & "*.jpg", vbNormal)
Do While Len(FName) > 0
ActiveSheet.Pictures.Insert(MyPath & FName).Select
Selection.BottomRightCell.Offset(20).End(xlToLeft).Select
FName = Dir
Loop
'code to make all images the same size
For Each shp In ActiveWorkbook.ActiveSheet.Shapes
wfactor = 7 * 72 / shp.Width
shp.Height = shp.Height * wfactor
shp.Width = shp.Width * wfactor
Next shp
End Sub
Obviously I amended the file location in MyPath to "Macintosh HD:Users:Rocuments:Atlashotos"
Thanks heaps. Regards
Hello
New to Excel 2004 - regular user of Excel 2007
I have a number of macros in a spreadhseet which were written for MS Excel 2007. They work fine on my pc.
One of the users of the spreadsheet is on a Mac using Excel 2004.
The following Excel 2007 macro (which inserts all jpg images contained in a folder in a directory into a worksheet - noting there will be a variable number of images each time the macro is run - hence reason they are not individually named) works fine in 2007 but does nothing in Excel 2004.
Suspect it has to do with my limited mac knowledge - especially about naming conventions and/or the use of the wildcard. Or maybe the file extension (something other than jpg perhaps). Yep, struggling to know what!!!
Any advice, or code which will work (i.e grab all images from a folder, insert them into one worksheet and then ensure all the same size)would be greatly appreciated.
The location of the jpgs on the Mac is Macintosh HD:Users:Rocuments:Atlashotos
Here is the 2007 code
Sub InsertPix()
'Inserts all pictures from selected directory on top of each other in worksheet.
Dim MyPath As String
Dim FName As String
MyPath = "C:\Users\Nat\Templates\"
FName = Dir(MyPath & "*.jpg", vbNormal)
Do While Len(FName) > 0
ActiveSheet.Pictures.Insert(MyPath & FName).Select
Selection.BottomRightCell.Offset(20).End(xlToLeft).Select
FName = Dir
Loop
'code to make all images the same size
For Each shp In ActiveWorkbook.ActiveSheet.Shapes
wfactor = 7 * 72 / shp.Width
shp.Height = shp.Height * wfactor
shp.Width = shp.Width * wfactor
Next shp
End Sub
Obviously I amended the file location in MyPath to "Macintosh HD:Users:Rocuments:Atlashotos"
Thanks heaps. Regards