Excel精英培训网

 找回密码
 注册
数据透视表40+个常用小技巧,让你一次学会!
查看: 1315|回复: 0

用vb把vba代码封装dll时,这个vba代码怎么改写?请高手帮忙!!!!

[复制链接]
发表于 2012-3-22 12:30 | 显示全部楼层 |阅读模式
用vb把vba代码封装dll时,这个vba代码怎么改写?请高手帮忙!!!!

Public Sub auto_open()   
    On Error Resume Next
   
Application.CommandBars(1).Reset
Application.CommandBars(1).Controls("Qopani").Delete
Dim myControlButton As Object
   
    Dim sani%
    sani = Application.CommandBars(1).Controls.Count
    Set myControlButton = Application.CommandBars(1).Controls.Add( _
        Type:=msoControlButton, Before:=sani + 1)
    With myControlButton
        .Caption = "Qopani"
        .OnAction = "Qopani1"
        .Style = msoButtonCaption
    End With
End sub

Public Sub fffff()
     Dim i%, Ps%
    Ps = ExecuteExcel4Macro("GET.DOCUMENT(50)")
   Select Case Ps
   Case Is > 0
        If MsgBox(vbCrLf & "nnnn" ,vbQuestion + vbOKCancel, "  ttt") = vbOK Then
        
        ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
        
       Else
        
         For i = 1 To Ps Step 1
              ActiveSheet.PrintOut From:=i, To:=i
         Next i
      
        End If
   Case Is = 0
      
        MsgBox vbCrLf & vbCrLf & "   rrrr " , vbQuestion + vbOKOnly, "  ttt"
     
   End Select
   
End Sub

Public Function Page(x As Range, z As Byte)
Dim ih%
Dim yh As Variant
    If z = 0 Then
        ih = 0
        For Each yh In ActiveSheet.HPageBreaks
            ih = ih + 1
            If x.Row <= yh.Location.Row Then
                Page = ih
                Exit Function
            End If
        Next yh
        Page = ih + 1   
    Else
        Page = (ActiveSheet.HPageBreaks.Count + 1) * (ActiveSheet.VPageBreaks.Count + 1)   
    End If
    Application.Volatile  
End Function
Public Sub yyyy()
    Dim x As Variant
    Dim c As Variant
    Dim m As Variant
    Dim p As Variant
   
    x = ActiveCell.Address
   
    Application.ScreenUpdating = False
   
    c = ActiveSheet.VPageBreaks.Count
   
    If c >= 1 Then m = ActiveSheet.VPageBreaks(1).Location.Column
   
    ActiveWindow.View = 2
   
    p = Page(ActiveCell, 0)
   
    If ActiveCell.Column >= m Then p = p + ActiveSheet.HPageBreaks.Count + 1
   
    ActiveWindow.View = 1
   
    msgbox p
end sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|Excel精英培训 ( 豫ICP备11015029号 )

GMT+8, 2024-5-18 23:52 , Processed in 0.248953 second(s), 11 queries , Gzip On, Yac On.

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表