Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-06-2024, 07:38 PM
stevenjohnson stevenjohnson is offline Modifying Macropod's Macro (Insert Multiple Images with Caption) Windows 10 Modifying Macropod's Macro (Insert Multiple Images with Caption) Office 2016
Novice
Modifying Macropod's Macro (Insert Multiple Images with Caption)
 
Join Date: Feb 2024
Location: California
Posts: 2
stevenjohnson is on a distinguished road
Default Modifying Macropod's Macro (Insert Multiple Images with Caption)

I have no business playing messing around with macros but I'm trying to make my work life a bit easier so here goes.

I used Macropod's code from this sticky: https://www.msofficeforums.com/drawi...-document.html



I changed it up so that the inserted photos are of certain dimension and whatnot. I got a couple of questions on how to change parts of the macro so that:

1) The caption cells will always have a shading of "White, Background 1, Darker 25%"
2) The caption template will always be:
Figure (numeric value)
Comment:
3) The caption font will always be Black, Times New Roman, Font 12
4) The caption [paragraph] will have 0 pt for before and after spacing and single line spacing

5) The macro table (the image and its caption) will always be horizontally centered to the entire page. Vertically centered would be a bonus but my work documents have header/footer information which I currently do not have the dimensions to right now.

The bolds above are priority. I've also attached an example of what I'm looking for.

For caption 2, I was able to extend the height of the caption so that the words don't get cut off when I write a full sentence, but I cannot extend the height of the caption for caption 1 (due to inserted photo constraints?). I would like the height of the caption to be like caption 2 and not caption 1.

This template is based on Macropod's Macro mixed with my memory of what my work's template looks like. I'll have to go into the office tomorrow and see the official template but I might be content with a Modified Macropod Macro.
Attached Files
File Type: docx Template.docx (37.2 KB, 2 views)
Reply With Quote
  #2  
Old 02-07-2024, 04:16 AM
Italophile Italophile is offline Modifying Macropod's Macro (Insert Multiple Images with Caption) Windows 11 Modifying Macropod's Macro (Insert Multiple Images with Caption) Office 2021
Expert
 
Join Date: Mar 2022
Posts: 338
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by stevenjohnson View Post
1) The caption cells will always have a shading of "White, Background 1, Darker 25%"
In the FormatRows routine add the following to the "With .Rows(x + 1)" block

Code:
.Cells.Shading.BackgroundPatternColor = -603930625
Quote:
Originally Posted by stevenjohnson View Post
2) The caption template will always be:
Figure (numeric value)
Comment:
Comment out the line that adds the Picture caption label:
Code:
CaptionLabels.Add Name:="Picture"
Change the line that inserts the caption to use the Figure label
Code:
.Characters.First.InsertCaption _
          Label:="Figure", Title:=StrTxt, _
Edit the lines that set StrTxt to contain the additional text that you require.

Quote:
Originally Posted by stevenjohnson View Post

3) The caption font will always be Black, Times New Roman, Font 12
4) The caption [paragraph] will have 0 pt for before and after spacing and single line spacing
Simply modify the Caption style in the template you use for this document.

Quote:
Originally Posted by stevenjohnson View Post
5) The macro table (the image and its caption) will always be horizontally centered to the entire page. Vertically centered would be a bonus but my work documents have header/footer information which I currently do not have the dimensions to right now.
Add the following in the With oTbl block just before the End With

Code:
      .Rows.RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
      .Rows.HorizontalPosition = wdTableCenter
      .Rows.RelativeVerticalPosition = wdRelativeVerticalPositionPage
      .Rows.VerticalPosition = wdTableCenter
Quote:
Originally Posted by stevenjohnson View Post
For caption 2, I was able to extend the height of the caption so that the words don't get cut off when I write a full sentence, but I cannot extend the height of the caption for caption 1 (due to inserted photo constraints?). I would like the height of the caption to be like caption 2 and not caption 1.
Just select the row and set the height on the Table Layout tab. This will also give you the value to set the height to in the FormatRows routine.
Reply With Quote
  #3  
Old 02-07-2024, 07:28 AM
stevenjohnson stevenjohnson is offline Modifying Macropod's Macro (Insert Multiple Images with Caption) Windows 10 Modifying Macropod's Macro (Insert Multiple Images with Caption) Office 2016
Novice
Modifying Macropod's Macro (Insert Multiple Images with Caption)
 
Join Date: Feb 2024
Location: California
Posts: 2
stevenjohnson is on a distinguished road
Default

Thanks for your reply, Italophile!

So I was able

1) Change the caption cell color
5) Macro aligned horizontally and vertically centered
6) Change the Caption Height

As for the labels and whatnot inside the gray caption cell, mine comes out as attached.

How do I go from

"Figure 1Comment:"

to

"Figure 1
Comment: "

(basically putting the "Comment: " line under the "Figure" line).

My macro line for that is currently set up as:

Label:="Figure", Title:="Comment: ", _

Also when you mentioned for the font style "Simply modify the Caption style in the template you use for this document.", it went completely over my head

I know it seems very elementary but this is coming from someone with absolutely 0 background on these things!
Attached Images
File Type: jpg Caption Cell.JPG (6.1 KB, 11 views)
Reply With Quote
  #4  
Old 02-07-2024, 08:09 AM
Italophile Italophile is offline Modifying Macropod's Macro (Insert Multiple Images with Caption) Windows 11 Modifying Macropod's Macro (Insert Multiple Images with Caption) Office 2021
Expert
 
Join Date: Mar 2022
Posts: 338
Italophile is just really niceItalophile is just really niceItalophile is just really niceItalophile is just really nice
Default

Quote:
Originally Posted by stevenjohnson View Post
As for the labels and whatnot inside the gray caption cell, mine comes out as attached.

How do I go from

"Figure 1Comment:"

to

"Figure 1
Comment: "

(basically putting the "Comment: " line under the "Figure" line).

My macro line for that is currently set up as:

Label:="Figure", Title:="Comment: ", _
You just need to add a carriage return:
Code:
Label:="Figure", Title:=vbCr & "Comment: "
Quote:
Originally Posted by stevenjohnson View Post

Also when you mentioned for the font style "Simply modify the Caption style in the template you use for this document.", it went completely over my head

I know it seems very elementary but this is coming from someone with absolutely 0 background on these things!
Display the Styles pane (Alt+Ctrl+Shift+S), locate the Caption style, right click and select modify.
Reply With Quote
  #5  
Old 02-07-2024, 09:07 AM
Charles Kenyon Charles Kenyon is online now Modifying Macropod's Macro (Insert Multiple Images with Caption) Windows 11 Modifying Macropod's Macro (Insert Multiple Images with Caption) Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,140
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by stevenjohnson View Post
Also when you mentioned for the font style "Simply modify the Caption style in the template you use for this document.", it went completely over my head

I know it seems very elementary but this is coming from someone with absolutely 0 background on these things!
It is time that you learned because styles are central to how Word formats text. Before you start trying to control formatting using macros, it is essential that you have a grasp of how styles are used. Otherwise, you are trying to reinvent the wheel and coming up with a square wheel!
Without a sound basic understanding of how Word is working, under the hood, writing or modifying macros is going to be extremely frustrating. Just trying to use Word to do anything other than type a basic letter or note is going to be challenging.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying Macropod's Macro (Insert Multiple Images with Caption) 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
Modifying Macropod's Macro (Insert Multiple Images with Caption) Need Help modifying code for inserting multiple images atifsyed Word VBA 8 05-17-2022 07:31 PM
Modifying Macropod's Macro (Insert Multiple Images with Caption) Macro to insert multiple images into a table Penini Word VBA 1 03-23-2022 02:30 PM
Insert multiple images at once from a folder beyondimage Excel 1 02-01-2017 12:58 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:00 PM.


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