Inserting caption in table
Inserting caption in table
Inserting caption in table
Inserting caption in table
Inserting caption in table
Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table
Inserting caption in table Inserting caption in table
Inserting caption in table
Go Back  Xtreme Visual Basic Talk > > > > Inserting caption in table


Reply
 
Thread Tools Display Modes
  #1  
Old 08-27-2016, 05:53 PM
jim77 jim77 is offline
Newcomer
 
Join Date: Aug 2016
Posts: 8
Default Inserting caption in table


Hello,
I have a table with multiple rows. I am using the following code to select the cell in the next to the last row. With that cell selected, the following code works great to insert the image in that cell. The problem is that it inserts the caption UNDER the table and I would like to insert it in the cell under the image(the last row).

Code:
Sub insertPicture()
    Dim Doc As Dialog
Dim BClicked As String
Dim picPath As String
Dim picName As String

Set Doc = Dialogs(wdDialogInsertPicture)
With Doc
.Name = "*.jpg"
BClicked = .Show 'using show executes the dialog
picPath = .Name
End With
'strip off the path to get the file name
picName = Right(picPath, Len(picPath) - InStrRev(picPath, "\"))

'only do this if OK was clicked
If BClicked = -1 Then
Selection.InsertCaption Label:="Figure", _
TitleAutoText:="", Title:=": " & picName, _
Position:=wdCaptionPositionBelow
End If
End Sub
Reply With Quote
  #2  
Old 08-28-2016, 12:06 PM
jim77 jim77 is offline
Newcomer
 
Join Date: Aug 2016
Posts: 8
Default

Solved:
Code:
Sub insertPicture() 
    Dim strName As String 
    Dim lngCol As Long 
    With Dialogs(wdDialogInsertPicture) 
        .Name = "*.jpg" 
        If .Show = -1 Then 
            lngCol = Selection.Range.Information(wdEndOfRangeColumnNumber) 
            strName = Right(.Name, Len(.Name) - InStrRev(.Name, "\")) 
            With Selection.Rows(1).Next.Cells(lngCol).Range 
                .InsertBefore vbCr 
                .Characters.First.InsertCaption Label:="Picture", _ 
                TitleAutoText:="", Title:=": " & strName, _ 
                Position:=wdCaptionPositionBelow 
                .Characters.First.Delete 
                .Characters.Last.Previous.Delete 
            End With 
        End If 
    End With 
End Sub
Reply With Quote
Reply

Tags
cell, dim, doc, string, picname, table, bclicked, insert, .name, caption, picpath, dialog, code, row, lenpicpath, file, strip, path, rightpicpath, selection.insertcaption, label=figure, titleautotext=, title=, clicked, multiple


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Inserting caption in table
Inserting caption in table
Inserting caption in table Inserting caption in table
Inserting caption in table
Inserting caption in table
Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table Inserting caption in table
Inserting caption in table
Inserting caption in table
 
Inserting caption in table
Inserting caption in table
 
-->