|
-
Jan 21st, 2006, 05:15 AM
#1
Thread Starter
Lively Member
[RESOLVED] How to add lines and tab spaces to a Word doc
Hello all
I have a Word 2003 userform. The options selected within the userform are used to build a quotation by adding text to bookmarks within the document.
I now want to add a "features list" to the document, which can vary in length depending on what is being quoted, e.g. it could contain 5 items or it could contain 10 items. The Word list is something like this:
Item 1: Details for item 1
Item 2: Details for item 2
Item 3: Details for item 3
and so on...
Items 1-3 are universal and so are in the document already as standard text. What I am trying to find out is a means to add the extra lines necessary, but also apply the same tab spaces between "Item n:" and "Details for item n".
At the moment, I have a bookmark at the end of the line containing item 3. If it is necessary to add another item I simply use vbCr to move to the next line, but I don't know how to add the tab.
Adding the extra lne using the above method is also possibly not the best method because I create strings depending on choices made. Some of the strings may be blank. I then simply use:
VB Code:
.Bookmarks("Features").Range.Text = vbCr & strItem4 & vbCr & strItem5 & vbCr & strItem6 etc
But I don't know how to disregard blank strings to avoid adding extra lines.
Any help would be greatly appreciated.
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
Jan 21st, 2006, 06:39 AM
#2
Re: How to add lines and tab spaces to a Word doc
Sounds like you should be placing the data in a table. That will help with the Tabs as columns and identifing rows or cells for adding data.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 21st, 2006, 12:55 PM
#3
Thread Starter
Lively Member
Re: How to add lines and tab spaces to a Word doc
 Originally Posted by RobDog888
Sounds like you should be placing the data in a table. That will help with the Tabs as columns and identifing rows or cells for adding data.
Thanks RobDog. I did consider using tables, but I have not used them before in conjunction with vba.
How do I add a row and how are cells identified?
Thanks again
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
-
Jan 21st, 2006, 01:11 PM
#4
Re: How to add lines and tab spaces to a Word doc
I take it you want to add them programmatically.
VB Code:
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=2, NumColumns:=5, _
DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Jan 22nd, 2006, 06:30 AM
#5
Thread Starter
Lively Member
Re: How to add lines and tab spaces to a Word doc
Thanks RobDog. I used the the code you kindly supplied to investigate further and found "InsertRowsBelow" which is perfect for what I am doing.
Much appreciated.
"Those things we must learn to do, we must learn by doing" (or hope somebody else will take pity and help out )
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|