标题:VB6读取Excel数据生成文件
只看楼主
zxh48911805
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2022-7-9
结帖率:100%
已结贴  问题点数:20 回复次数:3 
VB6读取Excel数据生成文件
VB6读取Excel数据生成文件,Excel表格锁定名字发生变化数据不变。改变名字也可以对应工作表!大神求解~~~
搜索更多相关主题的帖子: 生成 数据 Excel VB6 文件 
2022-10-17 11:21
约定的童话
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:47
帖 子:190
专家分:1061
注 册:2021-8-1
得分:20 
创建excel进程,打开指定路径工作簿,循环遍历工作表名称,根据表格单元内内容锁定工作表名称,然后进行操作....
2022-10-18 07:10
zxh48911805
Rank: 1
等 级:新手上路
帖 子:27
专家分:0
注 册:2022-7-9
得分:0 
可以给个代码吗谢谢
2022-10-18 08:41
约定的童话
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:47
帖 子:190
专家分:1061
注 册:2021-8-1
得分:0 
Private Sub Command6_Click(Index As Integer)    '导入BOM+CSV(GC)
    Dim i, n, c, ar, arr, br(1 To 1000, 1 To 2), brr, crr(1 To 10000, 1 To 6), fileDlg As Object, p, q, d As Object
    Dim xlExcel As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet As Excel.Worksheet
    Dim AppExcel As Object
    Set d = CreateObject("scripting.dictionary")
    Set xlExcel = CreateObject("Excel.Application")
    Set fileDlg = CreateObject(")    ' 打开附件
    p = Text3.Item(0)    '位号符
    q = Text4.Item(1)    '分割符
    t = "0123456789"
    fileDlg.DialogTitle = "选择BOM文件"    '先选择BOM文件
    fileDlg.Filter = "Excel (*.xlsx;*.xls)|*.xlsx;*.xls|"
    fileDlg.FilterIndex = 2
    fileDlg.ShowOpen
    If fileDlg.FileName <> "" Then
        xlExcel.Workbooks.Open fileDlg.FileName
        nm = Split(fileDlg.FileName, "\")(UBound(Split(fileDlg.FileName, "\")))
        Set xlBook = xlExcel.Workbooks(nm)
        Set xlSheet = xlBook.Worksheets(1)
        ar = xlSheet.UsedRange
        For i = 2 To UBound(ar)
            If ar(i, Form1.Text2.Item(1)) <> "" Then
                X = ar(i, Form1.Text1.Item(0))
                k = Split(ar(i, Form1.Text2.Item(1)), p)
                For j = 0 To UBound(k)
                    If InStr(k(j), q) Then
                        se = Split(k(j), q)
                        For m = Len(se(0)) To 1 Step -1
                            If InStr(t, Mid(se(1), m, 1)) = 0 Then Exit For
                        Next
                        s = Val(Mid(se(0), m + 1))
                        Y = Replace(se(0), s, "")
                        For m = Len(se(1)) To 1 Step -1
                            If InStr(t, Mid(se(1), m, 1)) = 0 Then Exit For
                        Next
                        e = Val(Mid(se(1), m + 1))
                        For m = s To e
                            n = n + 1
                            br(n, 1) = X
                            br(n, 2) = Y & m
                        Next
                    Else
                        n = n + 1
                        br(n, 1) = X
                        br(n, 2) = k(j)
                    End If
                Next
            End If
        Next
    Else
        rtnResult = True
        Exit Sub
    End If
2022-10-18 15:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510353-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.052629 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved