Exporting custome list from Excel into Word

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 code 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>
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
I also need to do several other things:

  1. 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>
  2. 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>
  3. I need designate that some but not all cells to begin on their own page.


I was able to do some of of my goals with the folowing code:

Sub main()</SPAN></SPAN>
Dim objWord As Object</SPAN></SPAN>
Dim objDoc As Object</SPAN></SPAN>
Set objWord = CreateObject("Word.Application")</SPAN></SPAN>
objWord.Visible = True</SPAN></SPAN>
Set objDoc = objWord.Documents.Add</SPAN></SPAN>
Dim i As Integer</SPAN></SPAN>
Dim strValue As String</SPAN></SPAN>
For i = 3 To 49
objDoc.Activate</SPAN></SPAN>
strValue = Cells(i + 1, 2)
objWord.Selection.TypeText Text:=strValue</SPAN></SPAN>
objWord.Selection.TypeParagraph</SPAN></SPAN>
Next i</SPAN></SPAN>
End Sub</SPAN></SPAN>
</SPAN>
 
Upvote 0

Forum statistics

Threads
1,214,846
Messages
6,121,905
Members
449,054
Latest member
luca142

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top