SendKeys PostMessage SendMessage [英] SendKeys PostMessage SendMessage
本文介绍了SendKeys PostMessage SendMessage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好团队,
谁能使用VBA指导我有关SendKeys或PostMessage或SendMessage到隐藏的应用程序的信息
例如
Hello Team,
Can anybody guide me about SendKeys OR PostMessage OR SendMessage to hidden application using VBA
e.g
Dim xl As New Excel.Application
xl.Workbooks.Add
xl.Visible=False
xl.Sendkeys("H")
xl.Sendkeys("I")
此代码应在Excel工作簿中写HI.
请帮助
this code should write HI in Excel Workbook.
Please help
推荐答案
您应该先使其可见,然后发送密钥:
You should make it first visible then send keys :
Dim xl As New Excel.Application
xl.Workbooks.Add
xl.Visible=True
xl.Sendkeys("H")
xl.Sendkeys("I")
我用CSharp进行了测试,效果很好.
如果您坚持要隐藏excel以便不能使用SendKeys,则应在确切的单元格中精确编写所需的内容:
I tested it with CSharp and it works well.
If you insist on having excel hidden so you can not use SendKeys you should write exactly what you want in a exact cell :
Worksheet ws = xl.ActiveSheet;
Range r = ws.Cells[1,1];
r.Value2 = "HI";
此代码在csharp中,请转换为VB;
希望对您有所帮助.
This code is in csharp convert it to VB please;
Hope it helps.
这篇关于SendKeys PostMessage SendMessage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文