Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-11-2024, 09:48 PM
sulav.gautam sulav.gautam is offline VBA to automatically insert photo number underneath all the images Windows 11 VBA to automatically insert photo number underneath all the images Office 2019
Novice
VBA to automatically insert photo number underneath all the images
 
Join Date: Dec 2024
Posts: 1
sulav.gautam is on a distinguished road
Post VBA to automatically insert photo number underneath all the images

Is there a way to automatically insert photo number under each photo inside a table. The word file will have multiple photos (up to 500) inside a table. Underneath each photos will be a brief comment for that photo. I am looking for a way to automatically insert photo caption like Photo 1 underneath each photo while maintaining the comment next to it. Kindly refer to the attached picture for reference.
Attached Images
File Type: png Photo vba.png (120.3 KB, 18 views)
Reply With Quote
  #2  
Old 12-12-2024, 02:27 AM
gmayor's Avatar
gmayor gmayor is offline VBA to automatically insert photo number underneath all the images Windows 10 VBA to automatically insert photo number underneath all the images Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

See Photo Gallery Add-in Template which will facilitate either option.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 12-12-2024, 04:40 AM
gmaxey gmaxey is offline VBA to automatically insert photo number underneath all the images Windows 10 VBA to automatically insert photo number underneath all the images Office 2019
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

While Graham's add-in is a logical step forward; if you just want to fix what you already have, you could try one of the following procedures:

Code:
Sub FixExisting()
Dim oTbl As Table
Dim oCell As Cell
Dim oRng As Range
Dim lngIndex As Long
  Set oTbl = Selection.Tables(1)
  lngIndex = 1
  For Each oCell In oTbl.Range.Cells
    If oCell.Range.InlineShapes.Count = 1 Then
      Set oRng = oCell.Range.InlineShapes(1).Range
      oRng.Collapse wdCollapseEnd
      oRng.InsertAfter "Picture " & lngIndex
      lngIndex = lngIndex + 1
    End If
  Next
lbl_Exit:
  Exit Sub
End Sub
Sub FixExistingII()
Dim oTbl As Table
Dim oCell As Cell
Dim oRng As Range
Dim lngIndex As Long
  Set oTbl = Selection.Tables(1)
  lngIndex = 1
  For Each oCell In oTbl.Range.Cells
    If oCell.Range.InlineShapes.Count = 1 Then
      Set oRng = oCell.Range.InlineShapes(1).Range
      oRng.Collapse wdCollapseEnd
      oRng.Move wdCharacter, 1
      oRng.InsertAfter "Picture " & lngIndex & " "
      lngIndex = lngIndex + 1
    End If
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #4  
Old 12-12-2024, 01:23 PM
macropod's Avatar
macropod macropod is offline VBA to automatically insert photo number underneath all the images Windows 10 VBA to automatically insert photo number underneath all the images Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,465
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See the Automate the Insertion of Multiple Images into a Document 'Sticky' thread at the top of the Drawing and Graphics forum:
https://www.msofficeforums.com/drawi...-document.html
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
photonum



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA to automatically insert photo number underneath all the images Insert photo gps information in column next to photo Belinda Burton Word VBA 4 11-11-2024 12:27 PM
VBA to automatically insert photo number underneath all the images VBA Module for inserting images into Photo Album Jjansens Word VBA 5 11-18-2022 03:43 PM
VBA to automatically insert photo number underneath all the images Macro to insert multiple images into a table with defined number of rows and columns Davidl88 Word VBA 6 09-05-2022 03:41 PM
Insert a line with text right underneath infinitedespair Word 1 10-28-2014 08:22 PM
VBA to automatically insert photo number underneath all the images insert photo on top of movie wabash12 PowerPoint 2 06-14-2013 06:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:12 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft