bwmustang13
New Member
- Joined
- Aug 22, 2014
- Messages
- 9
I am trying to create a list in excel for a list of about 60 items. The list is for people at work to be able to customize reports we print off. I want the user to be able to create 4 customized list of their choosing. I have created a master list of all the possible reports in columns B, E, and H. The user can then cut and paste any items into column L in their preferred order. Although some items in column B are just titles most are referencing a short explanation paragraph in its own worksheet. I am looking to have a VBA command that when executed exports the selected list and the referenced materials, into a new word document. Although I am very proficient with Excel, my VBA skills are meager at best. So if you post a solution please comment out each section so that I can understand the logic. Can anyone point me in the direction of how I can do this? </SPAN></SPAN>
I also need to do several other things:</SPAN></SPAN>
I was able to do some of of my goals with the folowing code:
Sub main()
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
Dim i As Integer
Dim strValue As String
For i = 3 To 49
objDoc.Activate
strValue = Cells(i + 1, 2)
objWord.Selection.TypeText Text:=strValue
objWord.Selection.TypeParagraph
Next i
End Sub</SPAN></SPAN>
I also need to do several other things:</SPAN></SPAN>
- I want to be able to keep the data formatted the way it is inputted into the excel document. I don’t want it to change when it goes into word. So for example I have it in 12 point Times New Roman.</SPAN></SPAN></SPAN>
- I need some but not all cells to have their own heading style and some cells need to continue that style while others will skip it. For example cell B5 heading style might be “1.0 Costs” and cell B8 might be “1.1 Direct Costs” then cell B13 might be “1.2 Indirect Costs”. All of these also need to be added to a table of contents as well.</SPAN></SPAN></SPAN>
- I need designate that some but not all cells to begin on their own page.</SPAN></SPAN></SPAN>
I was able to do some of of my goals with the folowing code:
Sub main()
Dim objWord As Object
Dim objDoc As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Add
Dim i As Integer
Dim strValue As String
For i = 3 To 49
objDoc.Activate
strValue = Cells(i + 1, 2)
objWord.Selection.TypeText Text:=strValue
objWord.Selection.TypeParagraph
Next i
End Sub</SPAN></SPAN>