Passing object as parameter

A

augustus

Hi,

in excel, i can pass object as parameter by simply:

Dim objCbx As ComboBox
Set objCbx = Sheet3.cbxMainData
Call Module1.Test(objCbx)

but in word, I can't
Dim objCbx As ComboBox
Set objCbx = ThisDocument.cbxMainData
Call Module1.Test(objCbx)

the objCbx under word will be empty.

Please tell me how to pass object in word.

Thanks.
 
J

Jezebel

Word VBA is syntactically identical to Excel's ... so the problem lies
elsewhere in your code.
 
A

augustus

Thanks Tony & Jezebel.

That's what I thought too. (Excel & Word syntact are the same)

THe following is my code:

Private Sub Document_Open()
Dim strSQL As String, strColumnLocation As String
Dim objCbx As ComboBox

strSQL = "SELECT * FROM [JobNo_JobName$]"
Set objCbx = Me.cbxJob
Call Module1.LoadDatabase(Me.cbxJob, "JobNo", strSQL)
End Sub

But when I run the code under debug mode (ie, F8 button), or query objCBx
inside Immediate mode, I get nothing. WHy?

I have also checked the Tools/Reference, anad ensure that it is identical to
Excel (of course replaced Excel Object with Word Object), but this didn't
help.
 

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