-
Apr 7th, 2006, 02:11 PM
#1
Thread Starter
Hyperactive Member
Passing document argument to form load sub
Hi everyone!
I have the following sub in a class module, and i want to pass the DocumentObject argument to a form load sub, How can i do this?
thanks.
*******Class module ****************
Private Sub MyAppEV_OnCloseDocument( _
ByVal DocumentObject As Document, _
ByVal FullFileName As String, _
ByVal BeforeOrAfter As EventTimingEnum, _
ByVal Context As NameValueMap, _
ByRef HandlingCode As HandlingCodeEnum _
)
Msgbox "the document name is "&DocumentObject
End Sub
-
Apr 7th, 2006, 02:22 PM
#2
Re: Passing document argument to form load sub
In another form?
VB Code:
'[In a Module]
Public MyDocumentObject As Document
'[In your sub]
Private Sub MyAppEV_OnCloseDocument( _
ByVal DocumentObject As Document, _
ByVal FullFileName As String, _
ByVal BeforeOrAfter As EventTimingEnum, _
ByVal Context As NameValueMap, _
ByRef HandlingCode As HandlingCodeEnum _
)
'...
MyDocumentObject = DocumentObject
'[In your other form]
Private Sub Form_Load()
MsgBox "the document name is " & MyDocumentObject
-
Apr 7th, 2006, 02:47 PM
#3
Thread Starter
Hyperactive Member
Re: Passing document argument to form load sub
HI,AI42, i did not understand your reply.
ok i have the following sub in a class module
and when i call the form1 in the class module, i want to acess the DocumentObject argument of the class module inside of the form load sub?
i hope you will understand this, Thanks?
*********Class module****
Private Sub MyAppEV_OnCloseDocument( _
ByVal DocumentObject As Document, _
ByVal FullFileName As String, _
ByVal BeforeOrAfter As EventTimingEnum, _
ByVal Context As NameValueMap, _
ByRef HandlingCode As HandlingCodeEnum _
)
Msgbox "the document name is "&DocumentObject
form1.show
End Sub
-
Apr 7th, 2006, 02:53 PM
#4
Hyperactive Member
Re: Passing document argument to form load sub
You can't pass anything directly into the Load event, but you can pass it to the form before the Load event so that it'll be there when the form is loaded:
VB Code:
' *** CLASS MODULE ***
Private Sub MyAppEV_OnCloseDocument( _
ByVal DocumentObject As Document, _
ByVal FullFileName As String, _
ByVal BeforeOrAfter As EventTimingEnum, _
ByVal Context As NameValueMap, _
ByRef HandlingCode As HandlingCodeEnum _
)
Dim frm As Form1
'Create the form, but don't load it.
Set frm = New Form1
'Pass a reference to the document to the form.
Set frm.DocumentObject = DocumentObject
'Load & show the form.
frm.Show
End Sub
VB Code:
' *** FORM CODE ***
Public DocumentObject As Document
Private Sub Form_Load()
MsgBox "Document name: " & DocumentObject
End Sub
-
Apr 7th, 2006, 03:02 PM
#5
Thread Starter
Hyperactive Member
Re: Passing document argument to form load sub
-
Apr 7th, 2006, 03:23 PM
#6
Re: Passing document argument to form load sub
Originally Posted by em07189
HI,AI42, i did not understand your reply.
ok i have the following sub in a class module
and when i call the form1 in the class module, i want to acess the DocumentObject argument of the class module inside of the form load sub?
You can do it the way em07189 showed you or you can make the value available in a global variable the way I showed you, so any part of the program can access it. Depending on what you're doing, sometimes it's more efficient one way, sometimes the other. And sometimes it doesn't matter.
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
|