VBA笔记
来源:互联网 发布:算法英语 编辑:程序博客网 时间:2024/04/30 15:18
example :
'@openFile,打开文件
Function openFile(buf As String, fileName As String)
Dim temp As String
Dim template As String
template = ActiveWorkbook.Path & "\" & fileName
Open template For Input As #1
Do While Not EOF(1)
Line Input #1, temp
buf = buf & temp & vbCrLf
Loop
Close #1
End Function
Function GetFolder(Optional msg) As String
Dim bInfo As BROWSEINFO, pPath As String
Dim R As Long, X As Long, pos As Integer
bInfo.pidlRoot = 0&
If IsMissing(msg) Then
bInfo.lpszTitle = "选择文件夹..."
Else
bInfo.lpszTitle = msg
End If
bInfo.ulFlags = &H1
X = SHBrowseForFolder(bInfo)
pPath = Space$(512)
R = SHGetPathFromIDList(ByVal X, ByVal pPath)
If R Then
pos = InStr(pPath, Chr$(0))
GetFolder = Left(pPath, pos - 1)
Else
GetFolder = ""
End If
End Function
'得到目标文件名
Public Function getDestFileName(ByVal fileName As String) As String
Dim pos1, pos2 As Integer
Dim destPath As String
pos1 = InStrRev(fileName, "\")
If (pos1 > 0) Then
fileName = Mid(fileName, pos1 + 1, (Len(fileName) - pos1))
End If
pos2 = InStrRev(fileName, ".")
If (pos2 > 0) Then
fileName = Mid(fileName, 1, pos2)
End If
destPath = Sheet1.Cells(20, 2).Value
getDestFileName = destPath & "\" & fileName & "cpy"
End Function
ref :http://www.excelperfect.com/index.php/technologybible/
https://msdn.microsoft.com/en-us/library/5z06z1kb.aspx
- VBA笔记
- VBA 笔记
- VBA笔记
- Excel VBA笔记
- Excel VBA笔记2
- VBA学习笔记
- Excel VBA编程笔记
- EXCEL VBA笔记
- VBA学习笔记
- Qt-Excel-vba笔记
- VBA 学习笔记 1
- VBA 学习笔记 2
- VBA学习笔记 3
- VBA 学习笔记 4
- Excel VBA 学习笔记
- VBA学习笔记
- VBA 入门笔记
- Excel VBA 代码笔记
- Lua学习之数据结构
- ASP开发入门+实战电子书共50本
- INSTALL_FAILED_INSUFFICIENT_STORAGE 的解决方法
- Android开发免豆资料(教程+工具+源码)下载地址汇总
- 安卓动画系列之五, 属性动画PropertyAnimation(下) - 通过官方例子深入了解
- VBA笔记
- hihocoder: 二分·二分查找之k小数
- centos7 ifconifg没有ip
- 一步一步学习ASP.NET 5 (三)- 认识新的Web结构
- 蓝桥杯 循环小数 模拟除法 解题报告
- 【c语言】从标准输入读取几行输入。每行输入都要打印到标准输出上,前面加上行号
- Linux7.0 NFS网络文件系统
- 作业2.2---信号报告
- 手机的Ram和Rom是什么意思