#1
|
|||
|
|||
Remove variable from text
Dear people of msofficeforums,
I have a VBA script, sourced from this forum (https://www.msofficeforums.com/word-...html#post47919), which works wonders. It looks like this: I want it to look like this (i want to remove the numbering from the image) This is the code: Code:
CaptionLabels.Add Name:="Step" For i = 1 To .SelectedItems.Count Step NumCols r = ((i - 1) / NumCols + 1) * 2 - 1 'Format the rows Call FormatRows(oTbl, r, RwHght) For c = 1 To NumCols j = j + 1 'Insert the Picture Set iShp = ActiveDocument.InlineShapes.AddPicture( _ FileName:=.SelectedItems(j), LinkToFile:=False, _ SaveWithDocument:=True, Range:=oTbl.Cell(r + 1, c).Range) With iShp .LockAspectRatio = True If (.Width < ColWdth) And (.Height < RwHght) Then .Width = ColWdth If .Height > RwHght Then .Height = RwHght End If End With StrTxt = "" With oTbl.Cell(r, c + 1).Range .Paragraphs.Alignment = wdAlignParagraphCenter .InsertBefore vbCr .Characters.First.InsertCaption _ Label:="Step", Title:=StrTxt, _ Position:=wdCaptionPositionBelow, ExcludeLabel:=False .Characters.First = vbNullString .Characters.Last.Previous = vbNullString End With 'Insert the Caption on the row below the picture CaptionLabels.Add Name:="Image" 'Get the image filename StrTxt = Split(.SelectedItems(j), "\")(UBound(Split(.SelectedItems(j), "\"))) StrTxt = ": " & Split(StrTxt, ".")(0) With oTbl.Cell(r, c).Range .InsertBefore vbCr .Characters.First.InsertCaption _ Label:="Image", Title:=StrTxt, _ Position:=wdCaptionPositionBelow, ExcludeLabel:=False .Characters.First = vbNullString .Characters.Last.Previous = vbNullString End With 'Exit when we're done |
#2
|
||||
|
||||
Follow what suggested in post #10 of the thread you linked.
That means you could apply these changes to this part of the macro: Code:
'... 'Get the Image name for the Caption StrTxt = Split(.SelectedItems(j), "\")(UBound(Split(.SelectedItems(j), "\"))) StrTxt = "Image " & Split(StrTxt, ".")(0) '<- changed oTbl.Cell(r + 1, c).Range.Text = StrTxt '<- added '-------------- do not use ---------------------------------------- 'Insert the Caption on the row below the picture 'With oTbl.Cell(r + 1, c).Range ' .InsertBefore vbCr '.Characters.First.InsertCaption Label:="Picture", Title:=StrTxt, _ ' Position:=wdCaptionPositionBelow, ExcludeLabel:=False ' .Characters.First = vbNullString ' .Characters.Last.Previous = vbNullString 'End With '------------------------------------------------------------------ 'Exit when we're done '... |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA to replace a repeated single variable with variable from a list | Edit4Fun | Word VBA | 13 | 08-31-2022 10:56 AM |
I want to create a bar chart of multiple variable. Then I need to draw trend lin of those variable | shimulsiddiquee | Excel | 1 | 05-16-2017 07:39 AM |
ord vba replace the variable text with variable images to make offer products with images | tanzinim | Word VBA | 4 | 12-30-2015 01:40 PM |
Run Time Error '91': Object variable or With block variable not set using Catalogue Mailmerge | Berryblue | Mail Merge | 1 | 11-13-2014 05:36 PM |
Run-time error 91 object variable or with block variable not set | JUST ME | Word VBA | 4 | 03-25-2014 06:56 AM |