0
매크로에 대해 작업하고 있는데 문제가 3 개 있습니다. 아마도 프로그래머의 경험에 따라 더 많을 것입니다. 지금 당장이 일을 할 수있는 코드를 얻으려고합니다. '할당 BK 전문가 :'사용자 입력이 대체 텍스트 여야 함
With ActiveDocument.Content.Find
.Text = "Assigned BK Specialist:"
.Replacement.Text = InputBox("Type in BK specialist's name.", "Mark Scott")
End With
Sub Combined_Code()
'Condense Version
Dim iRet As Integer
Dim strPrompt As String
Dim strTitle As String
Dim BkSpecName As String
For i = 1 To 2
With Selection.Find
.Text = "date received"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
End With
Selection.Find.Execute
Selection.Paste
Selection.MoveDown Unit:=wdLine, Count:=10
Next i
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3"
Selection.Find.Replacement.ClearFormatting
' Insert your name for the file.
With Selection.Find
.Text = "By:"
End With
Selection.Find.Execute
Selection.TypeText Text:="By: Robert Birch"
With Selection.Find
.Text = "Date Assigned:"
End With
' Insert current date on 3rd page.
Selection.Find.Execute
Selection.TypeText Text:="Date Assigned: "
Selection.InsertDateTime DateTimeFormat:="M/d/yyyy", InsertAsField:=False, _
DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
InsertAsFullWidth:=False
'Prompt
strPrompt = "What chapter is the MFR for?, NO = 13, Yes = 7"
'Dialog's Title
strTitle = "What Chapter Are You Working On?"
'Display MessageBox
iRet = MsgBox(strPrompt, vbYesNoCancel, strTitle, Yes = "Option1", No = "Option2")
'Check pressed button
If iRet = vbNo Then
MsgBox "Running Ch.13!"
' Added code for ch 13
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.MoveDown Unit:=wdLine, Count:=9
Selection.MoveRight Unit:=wdCell, Count:=2
For q = 1 To 7
Selection.TypeText Text:="x"
Selection.MoveDown Unit:=wdLine, Count:=1
Next q
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="2"
Selection.MoveDown Unit:=wdLine, Count:=10
Selection.MoveRight Unit:=wdCell, Count:=2
For w = 1 To 9
Selection.TypeText Text:="x"
Selection.MoveDown Unit:=wdLine, Count:=1
Next w
Else
MsgBox "Running Ch.7!"
' Added coded for Ch.7
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="1"
Selection.MoveDown Unit:=wdLine, Count:=9
Selection.MoveRight Unit:=wdCell, Count:=2
For b = 1 To 7
Selection.TypeText Text:="x"
Selection.MoveDown Unit:=wdLine, Count:=1
'modded
Next b
Selection.MoveDown Unit:=wdLine, Count:=10
For j = 1 To 3
Selection.TypeText Text:="x"
Selection.MoveDown Unit:=wdLine, Count:=1
Next j
Selection.TypeText Text:="n/a"
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeText Text:="n/a"
For o = 1 To 4
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.TypeText Text:="x"
Next o
End If
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:="3"
Selection.MoveDown Unit:=wdLine, Count:=9
Selection.MoveRight Unit:=wdCell, Count:=2
Selection.TypeText Text:="x"
Selection.MoveDown Unit:=wdLine, Count:=2
Selection.TypeText Text:="x"
'End part of program requires user input for BK spec's name
With ActiveDocument.Content.Find
.Text = "Assigned BK Specialist:"
.Replacement.Text = InputBox("Type in BK specialist's name.", "Mark Scott")
End With