Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-30-2022, 02:27 AM
jameson jameson is offline Remove variable from text Windows 10 Remove variable from text Office 2019
Novice
Remove variable from text
 
Join Date: Dec 2021
Posts: 4
jameson is on a distinguished road
Default 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
Reply With Quote
  #2  
Old 08-30-2022, 09:28 AM
rollis13's Avatar
rollis13 rollis13 is online now Remove variable from text Windows 10 Remove variable from text Office 2016
Competent Performer
 
Join Date: Jan 2021
Location: Cordenons
Posts: 140
rollis13 will become famous soon enough
Default

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
'...
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Remove variable from text 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
Remove variable from text 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
Remove variable from text Run-time error 91 object variable or with block variable not set JUST ME Word VBA 4 03-25-2014 06:56 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:31 AM.


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