Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bookmarking Footers or Connecting them To Input Boxes

Status
Not open for further replies.

Boots6

Technical User
Aug 12, 2011
91
US
Hello, I am using input boxes to quickly fill out an entire document with certain fields with this code (given to me by Andrzejek-many thanks):
Sub Subcontracter()
'
' Subcontracter Macro
'Dim strSubName As String
Dim i As Integer

strSubName = InputBox("Subcontractor")

With Selection
For i = 1 To 7
.GoTo What:=wdGoToBookmark, Name:="SubContr" & i
.TypeText Text:=strSubName
Next i

End With
End Sub

The problem is I cannot bookmark footers to include the data I need. Is there any way to do this or link it to words in the document so it fills itself in?


 

Is your Footer very complicated?
If not, why don't you create it 'on-the-fly' in the code.

I started with bank, new document, created a Macro that sets a Footer and got:
Code:
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.TypeText Text:=[blue]"This is my text in Footer."[/blue]
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

You can easily use your [tt]strSubName[/tt] instead of typed text:
Code:
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
If Selection.HeaderFooter.IsHeader = True Then
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Else
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
End If
Selection.TypeText Text:=[blue]strSubName[/blue]
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

Have fun.

---- Andy
 
The problem is, I had to seperate the document so I could have different headers and footers even though it is all one document. I was playing with trying to insert fields under the "quick parts" drop down on the Insert tab under Headers & Footers into the different footers where i could connect it to a formula or somehow to the different input boxes, but I haven't had much luck yet. Any familiarity with that?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top