excel VBA
来源:互联网 发布:帝妃娇 txt梅雨知时节 编辑:程序博客网 时间:2024/06/10 09:08
取得当前Sheet名
ActiveSheet.Name
'取得当前所有行数
ActiveSheet.UseRange.Rows.Count
'将生成的文本放在同目录下
Dim Path AS String '当前xls路径
Dim FileNameFile AS String '当前xls文件名,不带.xls
Dim FileNameSheet AS String '当前xls文件当前表sheet名称
Dim FileNameTime AS String '当前时间格式化
Dim Filename As String '生成文件名
Path = ThisWorkbook.Path
FileNameFile = Replace(ThisWorkbook.Name, ".xls", "")
FileNameSheet = ThisWorkbook.ActiveSheet.Name
FileNameTime = Format(Now(), "yyyymmddhhmmss")
Filename = Path & "/" & FileNameFile & "-" & FileNameSheet & "-" & FileNameTime & ".bat"
'取得当前表的内容
Public Function getValue(ByVal row, ByVal column)
Dim a, b As String
a = Application.ActiveSheet.Name
b = Sheets(a).Cells(row, column)
getValue = b
End Function
'给当前表某行某列赋值
Public Sub setValue(ByVal row, ByVal column, ByVal tableValue)
Dim a, b As String
a = Application.ActiveSheet.Name
Sheets(a).Cells(row, column) = tableValue
End Sub
'取得总行数
Public Function getRowNum()
Dim i, j As Integer
j = 1
For i = 2 To 1000
If getValue(i, 5) = "" Then
Exit For
Else
j = j + 1
End If
Next
getRowNum = j
End Function
写入文本
Sub WriteTxt(ByVal Flags As String, ByVal fName As String)
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fs, objFile As Object
Dim content, fileName As String
content = Flags
fileName = "e:/TestV30/" & fName
Set fs = CreateObject("Scripting.FileSystemObject")
Set objFile = fs.OpenTextFile(fileName, ForAppending, True)
objFile.Write content & vbCrLf
objFile.Close
Set objFile = Nothing
End Sub
- Excel Vba
- excel VBA
- Excel VBA
- EXCEL+VBA
- Excel VBA
- Excel VBA
- Excel VBA
- VBA Excel
- Excel中的VBA编程
- VBA for EXCEL FAQ
- Microsoft Excel VBA Examples
- Excel VBA 重要参考
- excel 问题,vba
- EXCEL VBA中的类
- Excel VBA教程
- 用VBA处理Excel
- Excel VBA笔记
- Excel VBA笔记2
- C语言中为文件设置安全属性(WIN)
- 第一篇博客
- 如何做才能从dll中导出类
- 递归删除文件夹下所有文件
- IT培训的7大陷阱——摘自《程序员羊皮卷》
- excel VBA
- BIOS的功能及作用
- directshow使用Sample Grabber采样
- 我有自己的博客了!
- EC的作用
- 用VC++建立Service服务应用程序
- WindowXP下osgWX osgGTK osgQT osgCEGUI编译小节
- 不小心,删错了,还把回收站清空了,咋办啊?
- android中wifi的上下层的连接、命令发送