Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-08-2015, 08:57 PM
Guessed's Avatar
Guessed Guessed is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

If you put this macro into your Excel workbook then it will create the Word document for you. Note that you need to add a Reference to the Word Object Library

Code:
Sub SendDataToWord()
  Dim appWord As Word.Application 'need reference to Microsoft Word x.x Object Library
  Dim docWord As Word.Document, rngDoc As Word.Range
  Dim paraWord As Word.Paragraph
  Dim rng As Excel.Range
  Dim i As Integer
  
  Set rng = ActiveSheet.UsedRange
  
  Set appWord = New Word.Application    'Create new instance of Word:
  appWord.Visible = True                'make the Word window visible:
  Set docWord = appWord.Documents.Add   'add a new word document:
  
  For i = 2 To rng.Rows.Count
    Set rngDoc = docWord.Content
    rngDoc.InsertParagraphAfter
    rngDoc.Collapse Direction:=wdCollapseEnd
    rngDoc.Text = rng.Cells(i, 1) & vbCr
    rngDoc.InsertAfter rng.Cells(i, 2)
    rngDoc.Style = "Normal"
    rngDoc.Paragraphs(1).Range.Style = "Heading 2"
    rngDoc.Collapse Direction:=wdCollapseEnd
    docWord.Endnotes.Add Range:=rngDoc, Text:=rng.Cells(i, 3).Text
  Next
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
endnotes, footnotes



Similar Threads
Thread Thread Starter Forum Replies Last Post
I want to create footnotes without numbers j hewitt Word 1 01-05-2015 10:26 AM
Automatically updating cross-references in Footnotes jessy_33 Word 1 05-07-2014 02:45 PM
create footnotes from custom text mosrozen Word VBA 2 06-14-2012 06:59 AM
Can Word automatically update footnotes? gib65 Word 2 08-15-2011 01:46 PM
automatically extract footnotes into new file and apply character format to footnote hrdwa Word 0 02-27-2010 03:16 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:53 PM.


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