Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-19-2021, 03:14 AM
SMehta SMehta is offline Trying to get number of para in Combobox Windows 10 Trying to get number of para in Combobox Office 2013
Novice
Trying to get number of para in Combobox
 
Join Date: Jan 2021
Posts: 29
SMehta is on a distinguished road
Default Trying to get number of para in Combobox

Hello



Basically i was tryling to upload the all the written paragraph numbers into Combobox
and not the Empty ones

I tried the following code but not able to upload the values in combobox one below the other

Code:
Dim aPar As Paragraph, sList As String, i As Long, sText As String, prghCnt As Integer, myArrayParaList As Variant

  For i = 1 To ActiveDocument.Paragraphs.Count
  sText = Trim(Trim(ActiveDocument.Paragraphs(i).Range.Text))
    If Split(sText, vbCr)(0) <> "" Then
           sList = sList & "," & i
           myArrayParaList = Array(sList)
    End If
  Next i
  cmbParaNos.List = myArrayParaList
Now i am unable to have values one below the other
Will appreciate if you could help me in correcting the same

Thank you
SMehta
Reply With Quote
  #2  
Old 02-20-2021, 04:47 AM
SamDsouza SamDsouza is offline Trying to get number of para in Combobox Windows 10 Trying to get number of para in Combobox Office 2013
Advanced Beginner
 
Join Date: Aug 2019
Posts: 71
SamDsouza is on a distinguished road
Default

SMehta

Try the following
Code:
Dim aPar As Paragraph, sList As String, i As Long, sText As String, prghCnt As Integer, myArrayParaList As Variant

  For i = 1 To ActiveDocument.Paragraphs.Count
  sText = Trim(Trim(ActiveDocument.Paragraphs(i).Range.Text))
    If Split(sText, vbCr)(0) <> "" Then
          sList = sList & i & ","
           myArrayParaList = Split(sList, ",")
    End If
  Next i
  
cmbParaNos.List = myArrayParaList
Changed the following line myArrayParaList = Array(sList) to myArrayParaList = Split(sList, ",")
This does the trick and you wiil have Para nos in your combobox one below the other.
SamD
Reply With Quote
  #3  
Old 02-20-2021, 07:15 AM
SMehta SMehta is offline Trying to get number of para in Combobox Windows 10 Trying to get number of para in Combobox Office 2013
Novice
Trying to get number of para in Combobox
 
Join Date: Jan 2021
Posts: 29
SMehta is on a distinguished road
Default

Thanks a tonne SamD
Indeed this was perfect one.
Now Slowly Getting bit familar with VBA-Word



SMehta
Thread 1: No: 46512 : Post No2 : TM 18
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trying to get number of para in Combobox Formatting is not confined to just the one para cryptogram Word 3 07-28-2015 12:45 PM
Trying to get number of para in Combobox Getting rid of para keystrokes at the end of every line baudinot Word 1 01-05-2012 03:37 PM
Don't add space between para of the same style ghumdinger Word 3 09-19-2011 02:04 AM
distorted last para lines when justifying RSF Word 0 08-18-2011 10:11 PM
Trying to get number of para in Combobox Tables that carry hidden para styles Ulodesk Drawing and Graphics 4 03-10-2011 08:16 AM

Other Forums: Access Forums

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


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