W
Wdd1
Hi All,
I was wondering if some one could help me. I'm trying to update an
old script that put "Page X of Y" in bottom of my word documents. The
word documents were being fed information from excel. I have this
script and it works well inside Word:
Sub Make_footer()
With Word.Application.ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
"C:\Program Files\Microsoft Office\Office12\Document Parts
\1033\Building Blocks.dotx"
.XMLSchemaReferences.AutomaticValidation = True
.XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
End With
Word.Application.WordBasic.ViewFooterOnly
Word.Application.ActiveDocument.AttachedTemplate.BuildingBlockEntries
("Bold Numbers 3").Insert Where:=Selection.Range, RichText:=True
Word.Application.ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
Inside of word, I don't get any errors. Bold Number 3 is a built in
Block. The problem occurs when I try to use Excel to output the
information in word. See below:
Sub Create_blank_copy()
MsgBox ("Create a new blank copy")
Cells(8, 11).Value = ""
Cells(19, 14).Value = "<- Complete"
Cells(25, 11).Value = "<- Complete "
Cells(30, 11).Value = ""
'Collect study info
study_number = InputBox("What is the study number?")
study_title = InputBox("What is the title of this round?")
'Look at question sheet
Sheets("Survey Questions Template").Visible = True
Sheets("Survey Questions Template").Activate
'Open Word
Dim AppWord As Word.Application
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
AppWord.Documents.Add
'Open Header & Footer, paste information
AppWord.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
AppWord.Selection.TypeText Text:="Macro v2.0" & vbTab & vbTab &
CStr(Date)
'Insert page numbers
With Word.Application.ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
"C:\Program Files\Microsoft Office\Office12\Document Parts
\1033\Building Blocks.dotx"
.XMLSchemaReferences.AutomaticValidation = True
.XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
End With
Word.Application.WordBasic.ViewFooterOnly
Word.Application.ActiveDocument.AttachedTemplate.BuildingBlockEntries
("Bold Numbers 3").Insert Where:=Selection.Range, RichText:=True
Word.Application.ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
When I run this macro I get, "Run Time Error 450: Wrong number of
arguments or invalid property assignment" on the
"Word.Application.ActiveDocument.AttachedTemplate.BuildingBlockEntries
("Bold Numbers 3").Insert Where:=Selection.Range, RichText:=True"
line. Does anyone know why or have an easier way of numbering pages?
I need the X of Y format.
Thanks!
I was wondering if some one could help me. I'm trying to update an
old script that put "Page X of Y" in bottom of my word documents. The
word documents were being fed information from excel. I have this
script and it works well inside Word:
Sub Make_footer()
With Word.Application.ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
"C:\Program Files\Microsoft Office\Office12\Document Parts
\1033\Building Blocks.dotx"
.XMLSchemaReferences.AutomaticValidation = True
.XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
End With
Word.Application.WordBasic.ViewFooterOnly
Word.Application.ActiveDocument.AttachedTemplate.BuildingBlockEntries
("Bold Numbers 3").Insert Where:=Selection.Range, RichText:=True
Word.Application.ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
Inside of word, I don't get any errors. Bold Number 3 is a built in
Block. The problem occurs when I try to use Excel to output the
information in word. See below:
Sub Create_blank_copy()
MsgBox ("Create a new blank copy")
Cells(8, 11).Value = ""
Cells(19, 14).Value = "<- Complete"
Cells(25, 11).Value = "<- Complete "
Cells(30, 11).Value = ""
'Collect study info
study_number = InputBox("What is the study number?")
study_title = InputBox("What is the title of this round?")
'Look at question sheet
Sheets("Survey Questions Template").Visible = True
Sheets("Survey Questions Template").Activate
'Open Word
Dim AppWord As Word.Application
Set AppWord = CreateObject("Word.Application")
AppWord.Visible = True
AppWord.Documents.Add
'Open Header & Footer, paste information
AppWord.ActiveWindow.ActivePane.View.SeekView =
wdSeekCurrentPageHeader
AppWord.Selection.TypeText Text:="Macro v2.0" & vbTab & vbTab &
CStr(Date)
'Insert page numbers
With Word.Application.ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = _
"C:\Program Files\Microsoft Office\Office12\Document Parts
\1033\Building Blocks.dotx"
.XMLSchemaReferences.AutomaticValidation = True
.XMLSchemaReferences.AllowSaveAsXMLWithoutValidation = False
End With
Word.Application.WordBasic.ViewFooterOnly
Word.Application.ActiveDocument.AttachedTemplate.BuildingBlockEntries
("Bold Numbers 3").Insert Where:=Selection.Range, RichText:=True
Word.Application.ActiveWindow.ActivePane.View.SeekView =
wdSeekMainDocument
End Sub
When I run this macro I get, "Run Time Error 450: Wrong number of
arguments or invalid property assignment" on the
"Word.Application.ActiveDocument.AttachedTemplate.BuildingBlockEntries
("Bold Numbers 3").Insert Where:=Selection.Range, RichText:=True"
line. Does anyone know why or have an easier way of numbering pages?
I need the X of Y format.
Thanks!