VBS 自动输入 第一格空白?
setoScrShell=WScript.CreateObject("WScript.Shell")oScrShell.appactivate"10.xlsx-Micro...
set oScrShell = WScript.CreateObject("WScript.Shell")
oScrShell.appactivate "10.xlsx - Microsoft Excel"//视窗名
yy = inputbox ("列数")
xx = INPUTBOX ("输入值")
oScrShell.sendkeys "{enter}" //至前视窗
sub down()
for i = 0 to yy
oScrShell.SendKeys "{DOWN}"
WScript.Sleep 100
oScrShell.SendKeys xx
next
end sub
sub right()
oScrShell.SendKeys "{RIGHT}"
WScript.Sleep 100
oScrShell.SendKeys xx
end sub
sub up()
for i = 0 to yy
WScript.Sleep 100
oScrShell.SendKeys "{UP}"
WScript.Sleep 100
oScrShell.SendKeys xx
next
end sub
for x = 1 to 3
call down()
if x = 3 then exit for
call right()
call up()
call right()
next
__________________
列数 输入5
输入值 输入10
为何列数=7?
A1 空白? 展开
oScrShell.appactivate "10.xlsx - Microsoft Excel"//视窗名
yy = inputbox ("列数")
xx = INPUTBOX ("输入值")
oScrShell.sendkeys "{enter}" //至前视窗
sub down()
for i = 0 to yy
oScrShell.SendKeys "{DOWN}"
WScript.Sleep 100
oScrShell.SendKeys xx
next
end sub
sub right()
oScrShell.SendKeys "{RIGHT}"
WScript.Sleep 100
oScrShell.SendKeys xx
end sub
sub up()
for i = 0 to yy
WScript.Sleep 100
oScrShell.SendKeys "{UP}"
WScript.Sleep 100
oScrShell.SendKeys xx
next
end sub
for x = 1 to 3
call down()
if x = 3 then exit for
call right()
call up()
call right()
next
__________________
列数 输入5
输入值 输入10
为何列数=7?
A1 空白? 展开
1个回答
展开全部
Set oScrShell = WScript.CreateObject("WScript.Shell")
oScrShell.appactivate "Microsoft Excel - 10.xls"
yy = inputbox ("行数")
xx = INPUTBOX ("输入值")
sub down()
for i = 0 to yy
oScrShell.SendKeys xx
WScript.Sleep 100
oScrShell.SendKeys "{DOWN}"
next
end sub
sub right()
oScrShell.SendKeys "{RIGHT}"
WScript.Sleep 100
end sub
sub up()
for i = 0 to yy
oScrShell.SendKeys "{UP}"
oScrShell.SendKeys xx
WScript.Sleep 100
next
end sub
for x = 1 to 3
call down()
if x = 3 then exit for
call right()
call up()
call right()
next
改了下,你再试试。那个Excel名称,我用的是2007版的,表头可能不一样,要注意下
oScrShell.appactivate "Microsoft Excel - 10.xls"
yy = inputbox ("行数")
xx = INPUTBOX ("输入值")
sub down()
for i = 0 to yy
oScrShell.SendKeys xx
WScript.Sleep 100
oScrShell.SendKeys "{DOWN}"
next
end sub
sub right()
oScrShell.SendKeys "{RIGHT}"
WScript.Sleep 100
end sub
sub up()
for i = 0 to yy
oScrShell.SendKeys "{UP}"
oScrShell.SendKeys xx
WScript.Sleep 100
next
end sub
for x = 1 to 3
call down()
if x = 3 then exit for
call right()
call up()
call right()
next
改了下,你再试试。那个Excel名称,我用的是2007版的,表头可能不一样,要注意下
更多追问追答
追问
试了 2行变多1行
不过有解决空白问题
我想知道你只使用这句吗?
oScrShell.appactivate "10.xlsx - Microsoft Excel"
那视窗会至前吗?
因为不至前 他不会输入 我想知道有方法後台输入?
不过也很矛盾 本身视窗至前又会空一格
我刚想了 有没有办法在我输入输入值後
停顿3~4秒 让我可以开启视窗点选指定位置後输入?
追答
建议看下VBS操作Excel的方法,具体写的话,有点多,就偷懒了,VBS操作Excel的方法,可以参考:
http://www.jb51.net/article/20919.htm
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询