C# 如何从Microsoft Excel获取滚动位置

C# 如何从Microsoft Excel获取滚动位置,c#,automation,ms-office,C#,Automation,Ms Office,使用Microsoft office automation时,我希望将图像插入电子表格。如何确定当前用户的滚动位置?在Excel中,您可以使用窗口对象的VisibleRange属性,即 Private Sub DirtyTest() Dim MyW As Window, TopRow As Long, TopCol As Long Set MyW = Windows(1) ' index 1 always refers to the window disp

使用Microsoft office automation时,我希望将图像插入电子表格。如何确定当前用户的滚动位置?

在Excel中,您可以使用窗口对象的VisibleRange属性,即

Private Sub DirtyTest()
Dim MyW As Window, TopRow As Long, TopCol As Long

    Set MyW = Windows(1)                ' index 1 always refers to the window displayed
    TopRow = MyW.VisibleRange.Cells.Row
    TopCol = MyW.VisibleRange.Cells.Column

    ' any other code

End Sub
希望有帮助

祝你好运,麦克