View Single Post
 
Old 05-25-2011, 02:03 AM
OTPM OTPM is offline Windows 7 32bit Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default Modify vba code to print based on name in the InputBox

Hi All
I need some help in modifying the vba code below so that it only prints a task sheet for the resource entered in the InputBox. I have tried and failed miserably. Any help would be appreciated.
Tony
Dim r As Resource
Dim ind As String
Dim myString As String
ViewApply Name:="Print Task Sheets For NHS Staff"
ind = InputBox("Enter Resource Name to print...")
If Response = "All" Then
GoTo PrintAllResourceSheets
Else: GoTo PrintIndividualResourceSheets
End If
'Code to print all Resource Sheets
PrintAllResourceSheets:
For Each r In ActiveProject.Resources
If r.Group = "NHS" Then
If r.Assignments.Count > 0 Then
myString = r.Name
FilterEdit Name:="Filter 1", TaskFilter:=True, Create:=True, _
OverwriteExisting:=True, FieldName:="Resource Names", test:="Contains exactly", _
Value:=myString, ShowInMenu:=True, ShowSummaryTasks:=False
FilterApply "Filter 1"
'Display Resource Name on each task sheet printed
FilePageSetupHeader Alignment:=pjRight, Text:="Resource Name: " & r.Name
SelectAll
' ZoomTimescale Selection:=True
SendKeys "{ENTER}"
FilePrintSetup "PDFCreator:"
FilePrintPreview
End If
End If
Next r
Reply With Quote