|
本人自行添加了“保区/读区(保存选择区域、读取选择区域)、列表框自动汇总功能
但有一小点问题没解决:在“读取选择区域”前要先用鼠标选取一下“RefEdit控件”,这样才不会出错,本来是用 refAddress.SetFocus来激活这个控件来达到目的,但想不到不成功!
Private Sub 创建文件_Click()
Dim fso As New FileSystemObject
Dim oStream As TextStream
Dim sFName As String, iFNumber As Integer, r As Long
sFName = "一片白云"
sFName = ThisWorkbook.Path & "\" & sFName & ".txt"
iFNumber = FreeFile '获取可用文件号
Open sFName For Output As #iFNumber '用Output方式打开文件
'For PL = 1 To lstRange.ListCount
'Write #iFNumber, lstRange.List(PL - 1) '向文件中写入数据
'Next
Close #iFNumber '关闭文件
Set oStream = fso.OpenTextFile(filename:=sFName, IOMode:=ForAppending)
For PP = 1 To lstRange.ListCount
oStream.WriteLine lstRange.List(PP - 1) '向文件中写入数据
Next PP
oStream.Close '关闭文本流对象
Set oStream = Nothing
Set fso = Nothing
End Sub
Private Sub 提取区域_Click()
lstRange.Clear
RenewTotalRanges
refAddress.SetFocus
Dim str1 As String, sFName As String, iFNumber As Integer, r As Long
Dim strRg As String
sFName = "一片白云"
sFName = ThisWorkbook.Path & "\" & sFName & ".txt"
If sFName = "False" Then Exit Sub
iFNumber = FreeFile '获取可用文件号
Open sFName For Input As #iFNumber '用Input方式打开文件
r = 2
Do
Line Input #iFNumber, str1
lstRange.AddItem str1, r - 2
strRg = lstRange.List(r - 2)
r = r + 1
Loop Until EOF(iFNumber)
Close #iFNumber '关闭文件
For LK = 1 To lstRange.ListCount
TotalRanges.Add lstRange.List(LK - 1)
Next
ShowObjranges
End Sub
[ 本帖最后由 杨成云 于 2009-9-1 11:18 编辑 ] |
|