Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 134 lines (104 sloc) 4.745 kb
fc6bdfe Initial Versions, current as of 06/30/11
unknown authored
1 Global ICFWD As ICFWRD 'required to have ICF_FN class module as well
2 Global ICF As ICFXL
3
4 Sub Test456()
5 Set ICFWD = New ICFWRD 'required to run intialize scripts at beginning of class
6
7 'setup
8 ' ICFWD.WordDocument_SelectActive
9 ICFWD.WordDocument_Add "C:\Documents and Settings\16955\Desktop\test", "newdoc", "doc"
10 ICFWD.WordCloseFile False
11 ICFWD.WordOptionsManual
12 ICFWD.WordVisible
13 ICFWD.PageMargins 2, 2, 1, 1
14 ICFWD.PageLandscape
15
16 ICFWD.AddPictureInline "C:\Documents and Settings\16955\My Documents\My Pictures\mo_100107c.jpg", 0.5, True
17 ICFWD.AddPictureShape "C:\Documents and Settings\16955\My Documents\My Pictures\mo_100107c.jpg", 0.5, True
18
19 'exit
20 ICFWD.WordVisible
21 ICFWD.SaveFile
22 ICFWD.WordOptionsAutomatic
23 ICFWD.WordCloseFile False
24
25 End Sub
26
27
28
29 'Code used to print something to Word
30 Private Sub CommandCommands()
31
32 'DEBUG W/ OPEN DOCUMENT
33 Set appWD = Word.Application
34
35 '/----------------------------------\
36 '| |
37 '| GENERAL FORMATTING OF DOC |
38 '| |
39 '\----------------------------------/
40
41 'STANDARDIZE PARAGRAPH FORMAT (REMOVE EXTRA SPACES, ETC)
42 StandardParagraphFormat
43
44 '/----------------------------------\
45 '| |
46 '| PRINTING AND FORMATTING TEXT |
47 '| |
48 '\----------------------------------/
49 'Print Word
50 WRD_PrintBoldText "Example header: "
51 WRD_PrintText ExcelWB.Sheets("Appendix Tables").Range("R24") & ", [ADD STATE]"
52 WRD_NextLine
53 WRD_PageBreak
54
55 'FORMATTING
56 appWD.Selection.Style = "Normal"
57 appWD.Selection.Font.Size = 12
58 appWD.Selection.Font.Bold = True
59 appWD.Selection.Font.Italic = True
60 appWD.Selection.Font.Name = "Calibri"
61 appWD.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
62
63 '/----------------------------------\
64 '| |
65 '| TABLES AND TABLE EDITS |
66 '| |
67 '\----------------------------------/
68
69 'CENTER TABLE
70 appWD.Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
71
72 'TABLE FORMATTING
73 appWD.Selection.Tables(1).Select
74 StandardParagraphFormat
75
76 'MERGE CELLS
77 appWD.Selection.Tables(1).Rows(1).Select
78 appWD.Selection.Cells.Merge
79
80 'COL WIDTH
81 appWD.Selection.Tables(1).Columns(1).SetWidth ColumnWidth:=Application.InchesToPoints(1.5), rulerstyle:=wdAdjustNone
82 appWD.Selection.Tables(1).Cell(2, 1).SetWidth ColumnWidth:=Application.InchesToPoints(0.35), rulerstyle:=wdAdjustNone
83
84 'ROW HEIGHT
85 appWD.Selection.Tables(1).Cell(2, j).SetHeight RowHeight:=Application.InchesToPoints(1), HeightRule:=wdRowHeightExactly
86
87 'VERTICAL CENTER TEXT
88 appWD.Selection.Tables(1).Cell(2, j).VerticalAlignment = wdCellAlignVerticalCenter
89
90 'HORIZONTAL ALIGN TEXT
91 appWD.Selection.Tables(1).Rows.Alignment = wdAlignParagraphLeft
92 appWD.Selection.Tables(1).Rows.Alignment = wdAlignRowCenter
93
94 'REMOVE TABLE INDENTS
95 appWD.Selection.Tables(1).Rows.LeftIndent = Application.InchesToPoints(0)
96
97 'SHADE SELECTION
98 appWD.Selection.Shading.BackgroundPatternColor = -570392321
99
100 'CLEAR BORDERS IN TABLE
101 WRD_ClearBorders
102
103 'ADD BORDER BACK IN TABLE
104 appWD.Selection.Borders(wdBorderBottom).Visible = True
105
106 '/----------------------------------\
107 '| |
108 '| CHARTS AND FIGURE EDITS |
109 '| |
110 '\----------------------------------/
111
112 'COPY ONE CHART FROM EXCEL TO WORD
113 Set ChartPaste = ExcelWB.Sheets("Graphs").ChartObjects("Math")
114 ChartPaste.ChartArea.AutoScaleFont = False 'DON'T RESIZE TEXT AUTOMATICALLY
115 ChartPaste.Copy
116 appWD.Selection.Paste
117 appWD.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter 'CENTER CHART
118
119 ' COPY MULTIPLE CHARTS FROM EXCEL TO WORD
120 For Each ChartID In ActiveSheet.ChartObjects
121 ChartID.ChartArea.AutoScaleFont = False 'stop resizing of text in chart
122 ChartID.Copy 'copy chart
123 appWD.Selection.Paste 'paste into MS Word
124 appWD.Selection.EndKey unit:=wdStory
125 WRD_NextLine
126 Next
127
128 '/----------------------------------------\
129 '| |
130 '| PASTE CHART FROM EXCEL, EDIT IN WORD |
131 '| |
132 '\----------------------------------------/
133
134 End Sub
Something went wrong with that request. Please try again.