Reputation: 1
i declared the global variable in the Module1 and when i was trying to use it in another module it is showing the runtime error '5':\invalid procedure call or argument. i was unable to find the problem please provied the solution for this problem Declaring global variable:
Function getFilePath() As String
getFilePath = FilePath
Set FilePath = "C:\quadyster\R3AgreementDetails"
End Function
Implementing of globalvariable:
Private Sub SendAgreement_Click()
If (Not IsNull(Me.RequestFrom) And Not IsNull(Me.RequestReference)) Then
Call AttachR3ServiceAgreement(Module1.FilePath, tripObjectFormation, "Agreement")
Me.AgreementDate = Now()
Else
MsgBox "Please provide 'RequestFrom' and 'RequestReference' to proceed." & vbNewLine & vbNewLine & _
"Press Ok to continue.", vbOKOnly, "Alert!!!"
End If
End Sub
this is the calling function
Public Function AttachR3ServiceAgreement(FilePath As String, tripData As
tripDetails, requestType As String)
Here error is occured: Set objStream = objFSO.OpenTextFile(fileHTML, ForReading)
Upvotes: 0
Views: 68
Reputation: 32642
You have a syntax error there: Set
can only be used with objects.
Public FilePath As String
Function getFilePath() As String
FilePath = "C:\quadyster\R3AgreementDetails"
getFilePath = FilePath
End Function
Private Sub SendAgreement_Click()
If (Not IsNull(Me.RequestFrom) And Not IsNull(Me.RequestReference)) Then
Call AttachR3ServiceAgreement(Module1.FilePath, tripObjectFormation, "Agreement")
Me.AgreementDate = Now()
Else
MsgBox "Please provide 'RequestFrom' and 'RequestReference' to proceed." & vbNewLine & vbNewLine & _
"Press Ok to continue.", vbOKOnly, "Alert!!!"
End If
End Sub
Upvotes: 0