Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-13-2020, 06:42 AM
gmayor's Avatar
gmayor gmayor is offline Word VBA coding for tables Windows 10 Word VBA coding for tables Office 2016
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

Without access to your building blocks - activedocument.tables (1) is the first table in the document, whereas you need to name the table so you can process it by name e.g.





Code:
Set oTbl = Selection.Tables(1)
oTbl.Cell(1, 1).Range.Select
__________________
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
  #2  
Old 02-13-2020, 07:12 AM
Dont know Dont know is offline Word VBA coding for tables Windows 10 Word VBA coding for tables Office 2016
Novice
Word VBA coding for tables
 
Join Date: Feb 2020
Posts: 5
Dont know is on a distinguished road
Default

Thanks for your reply, i changed the code to below, but get a run error 5941 now any ideas?


Sub TestCGBT()
Dim oTbl As Table
' TestCGBT Macro


Application.Templates("P:\Templates\CG Research Template.dotm"). _
BuildingBlockEntries("CG body text table").Insert Where:=Selection.Range, _
RichText:=True

Set oTbl = Selection.Tables(1)
oTbl.Cell(1, 1).Range.Select

Selection.SplitTable
Application.Templates("P:\Templates\CG Research Template.dotm"). _
BuildingBlockEntries("Figure 1: Title").Insert Where:=Selection.Range, _
RichText:=True
Selection.Delete Unit:=wdCharacter, Count:=1
Dialogs(wdDialogTableInsertTable).Show

End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
2 general question about coding puff Excel Programming 1 12-07-2017 08:53 AM
Word VBA coding for tables Problem Coding End of Page DRD992 Word VBA 1 10-12-2017 05:15 PM
Word VBA coding for tables If else statement-Need help with coding rsrasc Excel Programming 4 10-30-2015 01:10 AM
UserForm VBA coding Niclasfa Word VBA 1 04-08-2015 10:23 PM
What kind of coding? ep2002 Excel 3 07-22-2014 07:52 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:34 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