编译好类注册并引用后,为什么看不到属性?

wzh815 2003-07-22 10:42:45
The project name is "SaveWord" and the module name is "Toword".

There is a function named "UpdateWord" in this module.

But when I write the code: set ttt = createobject(saveword.

I want to see the function name, but nothing occured. It said"未找到方法或数据成员"

What's the matter?? Help me...


The module function is as following:
===========================

Public Function UpdateWord(strarr() As Byte) As Integer

Dim Wobj As Word.Application
Dim wordDoc As Word.Document

Set Wobj = CreateObject("Word.Application")

Set wordDoc = Wobj.Documents.Open("c:\subject.doc")

Wobj.Application.Visible = False

Wobj.Selection.Find.ClearFormatting
Wobj.Selection.Find.Replacement.ClearFormatting


For i = 1 To 10
If IsNull(strarr(i, 1)) = False And strarr(i, 1) <> "" Then

strRep = strarr(i, 2)

With Wobj.Selection.Find
.Text = strarr(1, 1)
.Replacement.Text = strRep
.Forward = True
.MatchByte = True
End With

Wobj.Selection.Find.Execute Replace:=wdReplaceAll


End If

Next i



wordDoc.Save
wordDoc.Close


Set wordDoc = Nothing
Set Wobj = Nothing

toword = 1

End Function
...全文
33 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
wzh815 2003-07-25
  • 打赏
  • 举报
回复
有哪位好心人啊。。。帮帮我啊。。
wzh815 2003-07-24
  • 打赏
  • 举报
回复
实时错误‘91’
对象变量或WITH块变量未设置?


===========

Private Sub Form_Load()


'Dim tt As Saveword.toword

Dim aa(2, 2) As String
Dim i As Integer


aa(1, 1) = "Subject"
aa(1, 2) = "menu"

Dim tt As toword

i = tt.UpdateWord(aa)


End Sub
wzh815 2003-07-24
  • 打赏
  • 举报
回复
how to? The class is ModuleClass.

>你必须把Module改成Class.
wzh815 2003-07-23
  • 打赏
  • 举报
回复
引用过了,但属性看不到。

>你可以在工程-》引用菜单中引用你的组件,然后声明的对象就可以看到了。
jordi2014 2003-07-23
  • 打赏
  • 举报
回复
用createobject定义对象是动态绑定的,所以该对象的属性和方法看不到;

你可以在工程-》引用菜单中引用你的组件,然后声明的对象就可以看到了。
jordi2014 2003-07-23
  • 打赏
  • 举报
回复
用createobject定义对象是动态绑定的,所以该对象的属性和方法;
你可以在工程-》引用菜单中引用你的组件,然后声明的对象就可以了。
wzh815 2003-07-23
  • 打赏
  • 举报
回复
》pigpag

CreateObject时点不开来,不象点其它的东东时点的开来。

》James0001
那我怎么使module成为public呢?

怎么解决"未找到方法或数据成员"这一问题?谁肯把我的代码试验一下呢?



pigpag 2003-07-23
  • 打赏
  • 举报
回复
我知道了,你必须把Module改成Class.
Module是不会提供类接口的。SaveWord里面没有任何接口可供外部使用。
since1990 2003-07-23
  • 打赏
  • 举报
回复
up
James0001 2003-07-22
  • 打赏
  • 举报
回复
The module you wrote is a private module (only visible to the classes/modules in the project 'SaveWord'), but not the "outsiders".
You should put the code in a standard, public class in order to be able to create an instance of it and invoke its methods.
Just remember, modules are ALWAYS private.
And, it's recommended to use compile-time-binding (namely, Project->Reference menu setting), rather than run-time-binding (namely, CreateObject, etc.)
pigpag 2003-07-22
  • 打赏
  • 举报
回复
CreateObject("类.成员"),注意,要加双引号的
不过老实说,你的Help Me之前的一段话,我不明白你的意思。
你的SaveWord工程是和主工程在一个工程组里面的吗?

7,763

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧