停止关闭 [英] stop word from closing

查看:96
本文介绍了停止关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试为我班上的学生编写一个代码,用于分配模板,但我不确定下一步该做什么有人可以帮我个忙吗



到目前为止,我所拥有的是一个包含此文字的文件。
"我,学生姓名,声明此作业是我自己的作品,除了我明确归于他人的内容。"


现在是什么我想要做的是当学生关闭它时,它会输入一个输入框,说明请输入你的名字但是学生仍然可以按下取消并离开它。


我怎么做到这样他们就不能离开文件,除非他们输入名字


这是我的代码



Private Sub Document_Close()

Dim rng As Range

设置rng = ThisDocument.Content

     rng.Find.Execute" student name",False ,,,,,,,, InputBox(" Enter Your Name"),wdReplaceAll

    ThisDocument.Save

End Sub


解决方案

尝试一下喜欢;

 Dim sname As String 

而Len(Trim(sName))= 0
sName = Trim(InputBox( "输入你的名字"))
Wend

'代码的余数



当然,如果您可以在表格中查找学生的姓名以确保他们输入有效内容,这将有所帮助名称


Hi,

i am trying to write a code for my students in my class for apart of there assignment template but i am not to sure what i have to do next could some one please give me a hand

what i have so far is a word document with this in it
"I, Student Name, declare that this assignment is my own work, excepting content that I have clearly attributed to others."

now what i am trying to do is when the student closes it it comes up with a input box saying please enter your name but the students can still press cancel and get out of it

how do i make it so they cant get out of the document unless they enter there name

this is the code i have

Private Sub Document_Close()
Dim rng As Range
Set rng = ThisDocument.Content
    rng.Find.Execute "student name", False, , , , , , , , InputBox("Enter Your Name"), wdReplaceAll
    ThisDocument.Save
End Sub

解决方案

Try something like;

Dim sname As String

While Len(Trim(sName)) = 0
    sName = Trim(InputBox("Enter your name"))
Wend

'Remainder of code
.
.
.

Of course it would help if you could then look up the student's name in a table to ensure they have entered a valid name.


这篇关于停止关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆