![]() |
Add multiple excel worksheets(tabs) with jpgs
I have several jpgs that have to be inserted into each separate
worksheet. Is it possible to batch this along with naming the worksheet tabs the jpg name? Regards Sunny |
This macro should do the job. Place all your .jpg files
into a new folder. Make sure to change "sPath" to your path and correct folder name (mine is named "thejpgs"). Sub Insert_JPG() Dim sPath As String Dim NewWS As Worksheet Dim PathArray As Variant Dim FileName As String sPath = "C:\Documents and Settings\jmorin\Desktop\thejpgs" With Application.FileSearch .NewSearch .LookIn = sPath .SearchSubFolders = False .FileName = "*.*" .FileType = msoFileTypeAllFiles If .Execute() 0 Then For i = 1 To .FoundFiles.Count PathArray = Split(.FoundFiles(i), "\") FileName = PathArray(UBound(PathArray)) Set NewWS = Sheets.Add ActiveSheet.Pictures. _ Insert (sPath & "\" & FileName) NewWS.Name = FileName Next Else MsgBox "There were no files found." End If End With End Sub --- HTH Jason Atlanta, GA -----Original Message----- I have several jpgs that have to be inserted into each separate worksheet. Is it possible to batch this along with naming the worksheet tabs the jpg name? Regards Sunny . |
Jason,
That worked wonders! Thanks a bunch! Sunny |
All times are GMT +1. The time now is 09:49 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com