|
-
Jun 20th, 2012, 04:39 AM
#1
Thread Starter
Junior Member
Popup in office (Macro)
Hello. Im new here and a newbie on VB.
I got like 100+ documents (word 2007 and excel 2007) and the main thing will be, to have the opportunity to choose a footer when you open a doc from a popup. im this case, three different offices.
This is my code:
Private Sub Document_New()
Call Document_Open
End Sub
Private Sub Document_Open()
Application.ScreenUpdating = False
Dim Rng As Range, Str As String, Fld As Field, i As Long
i = CLng(InputBox("Which Office?" & vbCr & "1: Gothenburg, 2: Stockholm, 3: Malmö"))
If i = 0 Or i > 3 Then Exit Sub
With ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary)
Set Rng = .Range.Characters.First
Rng.Collapse wdCollapseStart
For Each Fld In .Range.Fields
With Fld
If .Type = wdFieldQuote Then
Set Rng = Fld.Result
.Delete
Exit For
End If
End With
Next
Select Case i
Case 1
Str = "Gothenburg AB, Tel 010-123456, www.gothenburg.com"
Case 2
Str = "Stockholm AB, Tel 010-123456, www.stockholm.com"
Case 3
Str = "Malmö AB, Tel 010-123456,www.malmö.com"
End Select
Set Fld = ActiveDocument.Fields.Add(Range:=Rng, Type:=wdFieldQuote, _
Text:="""" & Str & """", PreserveFormatting:=False)
End With
Set Fld = Nothing: Set Rng = Nothing
Application.ScreenUpdating = True
End Sub
As it it now, the script change my footer on page 2 and forward. Is it possibly to change the first page as well?
Could you have different footer on different pages at the same time? In a script?
/KenZu
Last edited by KenZu; Jun 20th, 2012 at 05:01 AM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|