一、word的VBA问题,如何让光标移动到指定的位置
1、打开一个新建的Word文档,点击“插入”——“图片”——“来自文件”,选择一张图片插入到文档中。
2、然后需要在图片上任意位置,点击鼠标右键,选择“设置图片格式”。
3、设置完成,现在我们可以随意移动图片了,比如我把图片移动到了右下方。
二、word vba 光标竖直逐步向下移到底,直到移不动,相当于按键盘上的向
Sub gbxy()Dim i As Integer, starttime As Single, endtime As Single, rcount As Integerstarttime = Timerrcount = ActiveDocument.BuiltInDocumentProperties(wdPropertyLines).Value For i = 1 To rcount Delayms 500 Selection.MoveDown Unit:=wdLine, Count:=1 NextEnd SubPublic Sub Delayms(lngTime As Long) Dim starttime As Single Dim CostTime As Single starttime = Timer Do While (Timer - starttime) * 1000 < lngtime="" doevents="" loopend="">
想要光标移的快一点,改Delayms 500这边的数字,改的小就快,改大就慢。
三、word vba 怎么获取当前光标所在页码,并获取该页有多少行
Sub Macro2() Dim r, p, r0, p0, rr, pp p= Selection.Information(wdActiveEndPageNumber) '当前页码 r= Selection.Information(wdFirstCharacterLineNumber) '当前行 '数行数 p0 = p rr = r Do Selection.MoveDown Unit:=wdLine, Count:=1 pp = Selection.Information(wdActiveEndPageNumber) r0 = Selection.Information(wdFirstCharacterLineNumber) If pp > p Then '退回原处 Selection.MoveUp Unit:=wdLine, Count:=(rr - r + 1) Exit Do End If If rr = r0 Then '退回原处 Selection.MoveUp Unit:=wdLine, Count:=(rr - r) Exit Do End If rr = r0 Loop MsgBox "当前页码:" & p & vbCrLf & "本页总行数:" & rrEnd Sub 申请加悬赏分!!!。
转载请注明出处51数据库 » vbaword移动光标