Generating Word 2000 data from an Excel VBA program : Word Document « Word « VBA / Excel / Access / Word

VBA / Excel / Access / Word
1. Access
2. Application
3. Data Type
4. Data Type Functions
5. Date Functions
6. Excel
7. File Path
8. Forms
9. Language Basics
10. Math Functions
11. Outlook
12. PowerPoint
13. String Functions
14. Windows API
15. Word
16. XML
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
VBA / Excel / Access / Word » Word » Word Document 
Generating Word 2000 data from an Excel VBA program
 
Sub MakeMemos()
    Dim WordApp As Object
    Set WordApp = CreateObject("Word.Application")
    
    For i = To 3
        Application.StatusBar = "Processing Record " & i

        SaveAsName = ThisWorkbook.Path & "\test.doc"

        With WordApp
            .Documents.Add
            With .Selection
                .Font.Size = 14
                .Font.Bold = True
                .ParagraphFormat.Alignment = 1
                .TypeText Text:="M E M O R A N D U M"
                .TypeParagraph
                .TypeParagraph
                .Font.Size = 12
                .ParagraphFormat.Alignment = 0
                .Font.Bold = False
                .TypeText Text:="Date:" & vbTab & Format(Date, "mmmm d, yyyy")
                .TypeParagraph
                .TypeText Text:="To:" & vbTab & " Manager"
                .TypeParagraph
                .TypeText Text:="From:" & vbTab & _
                   Application.userName
                .TypeParagraph
                .TypeParagraph
                .TypeText "text"
                .TypeParagraph
                .TypeParagraph
                .TypeText Text:="Units Sold:" & vbTab & "asdf"
                .TypeParagraph
                .TypeText Text:="Amount:" & vbTab & Format(1000"$#,##0")
            End With
                .ActiveDocument.SaveAs FileName:=SaveAsName
                .ActiveWindow.Close
        End With
    Next i
    WordApp.Quit
    Set WordApp = Nothing
    Application.StatusBar = ""
    MsgBox " memos were created and saved in " & ThisWorkbook.Path
End Sub

 
Related examples in the same category
1. Add a word document
2. To create a new document that uses a specific template, use this:
3. Open an Existing Document
4. Save Changes to a Document
5. To save a document with a new name, use the SaveAs method
6. To close a specific document, you can close the active document or you can specify a document name:
7. Save a document
8. Load contact table from Access and create letter in Word
9. Close a document
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.