Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-03-2021, 06:00 AM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

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
Attached Files
File Type: docx BasicParameters.docx (15.0 KB, 2 views)
Reply With Quote
  #2  
Old 02-03-2021, 01:57 PM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

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]
Reply With Quote
  #3  
Old 02-04-2021, 09:13 PM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

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:
Representation : List of Returned Value of Objects
were completely removed then nos of paragraph were showing corrrectly.

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
Reply With Quote
  #4  
Old 02-04-2021, 09:32 PM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Quote:
Originally Posted by SamDsouza View Post
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

were completely removed then nos of paragraph were showing corrrectly.

If may i ask you why this happened ?
I have no idea what you mean.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 02-05-2021, 03:30 AM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

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
Reply With Quote
  #6  
Old 02-05-2021, 03:35 AM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Quote:
Originally Posted by SamDsouza View Post
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
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]
Reply With Quote
  #7  
Old 02-05-2021, 08:11 PM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Quote:
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.
Ok Now i understand

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:
Para No Style Alignment Font Name

001 Normal (Web) 0 Arial
002 Normal (Web) 0 Arial
003 Normal (Web) 0 Times New Roman
004 Normal (Web) 0 Arial
005 Normal (Web) 0 Arial
006 Normal (Web) 0 Arial
007 Normal (Web) 0 Arial
008 Normal (Web) 0 Arial
009 Normal (Web) 0 Arial
010 Normal (Web) 0 Arial
011 Normal (Web) 0 Arial
012 Normal (Web) 0 Arial
013 Normal 0 Arial
If you observe the above the last Para No 013 Style "Normal" Alignment 0 and font name Arial have shifted to left as there is no equal spacing.
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
SamD
Reply With Quote
  #8  
Old 02-05-2021, 08:47 PM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

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]
Reply With Quote
  #9  
Old 02-05-2021, 09:44 PM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Quote:
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.
Paul. Your point well taken
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
Reply With Quote
  #10  
Old 02-06-2021, 02:25 PM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

Quote:
Originally Posted by SamDsouza View Post
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
You could certainly do something like that, but but that would add a lot of processing for very little gain. Using tab separators and converting the output to a table (and back again if you don't want a table for the final output), would be far simpler and quicker.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 02-06-2021, 08:49 PM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Quote:
You could certainly do something like that, but but that would add a lot of processing for very little gain.
Was really intrested in deriving with function procedure so that everything remains neat for the representation

Quote:
Using tab separators and converting the output to a table (and back again if you don't want a table for the final output), would be far simpler and quicker.
This is something new for me
Output shall remain in textbox itself.

Will it be possible to show the two methods ?

SamD
Reply With Quote
  #12  
Old 02-06-2021, 10:09 PM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

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]
Reply With Quote
  #13  
Old 02-07-2021, 06:06 PM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Quote:
There are numerous threads on this forum showing the use of Word's ConvertToTable and/or ConvertToText methods.
Any link would you prefer to recommend to suit my needs.
Unfortunately I've not understood the concept of " Word's ConvertToTable and/or ConvertToText methods."
SamD
Reply With Quote
  #14  
Old 02-07-2021, 06:17 PM
macropod's Avatar
macropod macropod is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,225
macropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant futuremacropod has a brilliant future
Default

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]
Reply With Quote
  #15  
Old 02-08-2021, 04:02 AM
SamDsouza SamDsouza is offline To get Returned List Values of Objects Windows 10 To get Returned List Values of Objects Office 2013
Advanced Beginner
To get Returned List Values of Objects
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

Quote:
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:
Yes i went to below link and i did not understand
Table.ConvertToText method (Word) | Microsoft Docs

will try to go through the link below and study may take sometime
As i moved on leaving the above issues had query on Line Spacing and lineSpacingRule

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:
Alignment : Left
Outline Level :Body Text

Left Right 0Cm
Special : None
By :

Spacing
Before : 6 Pt
After : 6 Pt
Line Spacing : Multiple At:1.15
Also .LineSpacingRule Returned value was 5. What is this 5

SamD
Reply With Quote
Reply

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
To get Returned List Values of Objects 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
To get Returned List Values of Objects 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

Other Forums: Access Forums

All times are GMT -7. The time now is 03:41 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2021 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft