当前位置: 代码迷 >> PB >> PB中嵌ole 怎么写翻页
  详细解决方案

PB中嵌ole 怎么写翻页

热度:413   发布时间:2016-04-29 10:40:40.0
PB中嵌ole 如何写翻页
我用pb窗口中嵌了一个ole控件,调用的是word,excel文档,因为文档有很多页,所以我需要写个按钮对文档进行翻页,请问如何实现?

------解决方案--------------------
在word\excel里使用录制宏,通过手工翻页,录制下来
然后编辑宏,看代码,复制到pb里,ole_1.object.宏里的代码一般可以用
------解决方案--------------------
不会
------解决方案--------------------
ole_1.object.ActiveWindow.Selection.MoveDown(5, 2 )



ole_1.ActiveWindow.Selection.MoveDown(5, 2 )

试试

------解决方案--------------------
或者用send发送一个翻页的消息

可以参考VB代码


Public Declare Function SetForegroundWindow Lib "user32" Alias "SetForegroundWindow" (ByVal hwnd As Integer) As Integer
Public Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Private Const WM_KEYDOWN As Integer = &H100
Private Const WM_KEYUP As Integer = &H101

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
 
Dim h As Integer = FindWindow("screenClass", Nothing)
Dim h1 As Integer = FindWindowEx(h, 0, "paneClassDC", Nothing)

SetForegroundWindow(h)
PostMessage(h1, WM_KEYDOWN, Keys.Down, 10)
System.Threading.Thread.Sleep(100)
PostMessage(h1, WM_KEYUP, Keys.Down, 0)

End Sub
------解决方案--------------------
可以参考

http://topic.csdn.net/u/20080923/23/d06a1873-744c-48e8-b728-4704c04e0f77.html
------解决方案--------------------
mark
  相关解决方案