#1
|
|||
|
|||
Hello Can Anyone help me to code for the Following For a document to get Returned list values of Basic Objects List of Para numbers With Underlined, Strikethrough, Bold, Italic, Spacing Size of Para I've attached the file with the above implementation in order to get the list of Returned value of objects via coding SamD |
#2
|
||||
|
||||
For some code to get you started, see: Print Applied Document Formatting (not real styles) - Microsoft Community
Do note that there is a myriad of parameters that could be queried and, since font attributes can vary repeatedly within a paragraph, getting all of those into a report could both generate a very large, cumbersome output and take a long time to produce.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
Thanks Paul for the reference link.
I've to work on the same as per my requirement. Just one observation: When i implemented the code from the link on the document attached as per #1. the nos of paragrapah were approximately 70. But when the Table of Representation and para before the table quoted below Quote:
If may i ask you why this happened ? Let me work on the same and if any difficulty of deriving the returend value of object will surely post. in mean time you can reply on the above SamD |
#4
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Paul I implemented the same code after your reference link.
Would request you to check the Dcoument with code in that link. after i implemented the coding from the link it showed 70 Paras. But when the Table with rows and Columns were removed and para before the table removed it showed 13 paras in the attached document. So i wanted to know why it displayed 70 nos of paras with the table SamD |
#6
|
||||
|
||||
Simple: Your table has multiple cells (or one cell with 70 paragraphs), and each cell has one or more paragraphs. For example, suppose you have a 5*14 table. Even the empty cells have a single paragraph so far as Word is concerned. So, even if there were no paragraph breaks in the table, there would be an output for 70 paragraphs in the macro.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Quote:
As i began to code for what i desire Can you help me with equal nos of spacing between Style , Alignment and Font Name below is the representation in Textbox1 Quote:
How can i have equal spacing between Two Strings and later Equal spacing between Font name other Returned value of object and so on. Any kind of function to insert in code to achieve Equal spacing between the Returned value of objects leading to Neat representation I tried below with gapbetween as integer ,LEN ..... but somehow no success then used vbTab but still no success Code:
'Module1 Option Explicit Public Const minStrLen As Integer = 24 'Userform1 Private Sub ListBasicReturnedObjects() Dim StrData As String, StrSty As String, Sty As Style, strstylen As Integer Dim gapBetween As Integer Dim i As Long, j As Long, k As Long, bTabOK As Boolean, Rng As Range Dim bldFont As Boolean, strHeader As String, Pos As Integer, newPos As Integer Dim StrRecord As String strHeader = "Para No" & Space(5) & "Style" & Space(15) & "Alignment" & Space(2) & "Font Name" StrData = strHeader & vbCrLf With ActiveDocument.Range For i = 1 To .Paragraphs.Count With .Paragraphs(i) StrSty = .Style StrData = StrData & vbCr & Format(i, "#00#") & Space(8) & Mid(StrSty, 1, Len(StrSty)) strstylen = Len(Mid(StrSty, 1, Len(StrSty))) gapBetween = minStrLen - strstylen Set Sty = ActiveDocument.Styles(StrSty) If Sty.ParagraphFormat.Alignment <> .Alignment Then Else If gapBetween <= 15 Then StrData = StrData & vbTab & .Alignment & vbTab & .Range.Font.Name Else StrData = StrData & vbTab & .Alignment & vbTab & .Range.Font.Name End If End If End With Next TextBox1.Text = TextBox1.Text & StrData End With End Sub |
#8
|
||||
|
||||
You can't do that in advance, since you don't know beforehand, what Style names, fonts etc. are in use and how long their names are. Moreover, if the output is generated using proportional fonts, there is never a 1:1 relationship between the character counts and their widths. If you use tabs for the separators, none of this will be a problem; you can simply adjust the tab-stops to suit once the output is generated. Better still, if you convert the output to a table, Word will handle the alignments automatically for you.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Quote:
In this case the output is standard with different style, font names and size etc I was thinking on Total how may Styles are there in the Word Which Style (name) has maximum length. So let us keep the Len of the Style (name) which has maximum characters or letters. Same case for Font name, Alignment etc On Beforehand Knowing the LEN of Style(name) , LEN(Font.name), LEN(Alignment) which has max characters, keep that as Const and derive function for equal spacing between values of returned objects. Putting exact logic for a function is really difficult for me. Do we have vbTabstop like PRINT TAB(30); in VBA ? For each document no will know beforehand what style font name etc have been used. once running the macro shall give the details Therfore i used Textbox to get the details of Returned value of objects. This is for neat representation ie why exact spacing required SamD |
#10
|
||||
|
||||
Quote:
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
Quote:
Quote:
Output shall remain in textbox itself. Will it be possible to show the two methods ? SamD |
#12
|
||||
|
||||
There are numerous threads on this forum showing the use of Word's ConvertToTable and/or ConvertToText methods.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
Quote:
Unfortunately I've not understood the concept of " Word's ConvertToTable and/or ConvertToText methods." SamD |
#14
|
||||
|
||||
Did you at least do a forum search? I, for one, have posted macros using the ConvertToTable method in 20 threads and the ConvertToText method in 15 threads. See, for example:
https://www.msofficeforums.com/29083-post4.html https://www.msofficeforums.com/40087-post8.html or even: https://www.msofficeforums.com/39543-post2.html where both are used in the same macro!
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#15
|
|||
|
|||
Quote:
Table.ConvertToText method (Word) | Microsoft Docs will try to go through the link below and study may take sometime Quote:
As per attached file I had line Spacing done at 1.15 on document itself When coded it returned as 138 Could you explain what is 138 is it in inches cm or mm and when went into option of indent and spacing where Quote:
SamD |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Multiple found values from five sheets, multiple returned values in sheet six? | irisha | Excel Programming | 26 | 09-30-2016 01:20 AM |
Macros to move objects prevents moving same objects with arrow keys | BruceM | Word VBA | 1 | 03-10-2015 08:20 AM |
List of Objects for CreateObject | excelledsoftware | Excel Programming | 4 | 09-14-2014 08:47 PM |
Query list of objects and properties in VBA | bshawnr | Word VBA | 1 | 08-22-2013 11:03 PM |
Pivot Table:delete zero values when using calculated objects | Serge 007 | Excel | 1 | 06-05-2013 11:47 AM |