crowfan
10-04-2007, 11:22 AM
Hi all,
I'm just starting to work with UserForms and I have a question.
Here's the scenario: I have Word document (a manual), broken up into chapters. Each chapter is its own section. The Chapter heading is always contained in the first paragraph of the section.
I also have the need to create another document based on the first (sort of a quick reference guide), which takes the data out of the first document, and strips out the graphics and converts a bunch of styles.
So I thought it might be useful to create a custom UserForm. What I'd like to do, ideally, is to have the UserForm list all of the chapters from the main document as checkboxes. Then I could select the desired chapters, and the macro would then go through the manual and copy the selected chapters into the new document.
So I started with an array, to read the chapter titles into an array of strings. That's working well.
Dim strChapterArray() As String, i As Integer, intCount As Integer
intCount = 1
For i = 3 To ActiveDocument.Sections.Count
ReDim Preserve strChapterArray(intCount)
strChapterArray(intCount) = ActiveDocument.Sections(i).Range.Paragraphs(1).Range.Text
intCount = intCount + 1
Next i
Now I'd like to use the values in the array to create checkboxes on the UserForm. How would I go about doing that? I was thinking along these lines:
for each value in the array
create a checkbox on the user form, name it with the same name as the arry
next
Is this even possible? I am pretty good with Word VBA in general but very inexperienced with User Forms.
Thanks!
I'm just starting to work with UserForms and I have a question.
Here's the scenario: I have Word document (a manual), broken up into chapters. Each chapter is its own section. The Chapter heading is always contained in the first paragraph of the section.
I also have the need to create another document based on the first (sort of a quick reference guide), which takes the data out of the first document, and strips out the graphics and converts a bunch of styles.
So I thought it might be useful to create a custom UserForm. What I'd like to do, ideally, is to have the UserForm list all of the chapters from the main document as checkboxes. Then I could select the desired chapters, and the macro would then go through the manual and copy the selected chapters into the new document.
So I started with an array, to read the chapter titles into an array of strings. That's working well.
Dim strChapterArray() As String, i As Integer, intCount As Integer
intCount = 1
For i = 3 To ActiveDocument.Sections.Count
ReDim Preserve strChapterArray(intCount)
strChapterArray(intCount) = ActiveDocument.Sections(i).Range.Paragraphs(1).Range.Text
intCount = intCount + 1
Next i
Now I'd like to use the values in the array to create checkboxes on the UserForm. How would I go about doing that? I was thinking along these lines:
for each value in the array
create a checkbox on the user form, name it with the same name as the arry
next
Is this even possible? I am pretty good with Word VBA in general but very inexperienced with User Forms.
Thanks!