What's wrong with this macro code?

L

lamby74

Private Sub Project_BeforePrint(ByVal pj As Project)
MessageBox.Show "Are you sure you want to print this?", "Print Verify",
MsgBoxStyle.YesNo
If Dialogresult = yes Then
Cancel = False
ElseIf Dialogresult = no Then
Cancel = True
End If
End Sub

I want this to come up when a user clicks print - some of Projects reports
are hundreds of pages long, and I want another way to cancel an "accidentally
clicked on print job".

Thank you!
 
J

Jan De Messemaeker

How about using the constants vbyes and vbno?
The way it is written VBA will look for a variable called yes and another
called no.
HTH
 
L

lamby74

Still can't get this one to work. This is how it sits as of today, but I get
a compile error: argument not optional message when it executes:

Sub TWEAKLag_Lead()
Dim myString As String
Dim getpredecessor As Integer
Dim getlag As Integer
Dim t As Task

getpredecessor = InputBox("Enter predecessor.")
getlag = InputBox("Enter Lag Time (+) or Lead Time (-)")

myString = CStr(getpredecessor) & "SS+" & CStr(getlag) & "w"
SetTaskField field:="Predecessors", Value:=myString, AllSelectedTasks:=True

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top