| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1249 人关注过本帖
标题:VB6读取Excel数据生成文件
只看楼主 加入收藏
zxh48911805
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2022-7-9
结帖率:100%
收藏
已结贴  问题点数:20 回复次数:3 
VB6读取Excel数据生成文件
VB6读取Excel数据生成文件,Excel表格锁定名字发生变化数据不变。改变名字也可以对应工作表!大神求解~~~
搜索更多相关主题的帖子: 生成 数据 Excel VB6 文件 
2022-10-17 11:21
约定的童话
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:56
帖 子:246
专家分:1442
注 册:2021-8-1
收藏
得分:20 
创建excel进程,打开指定路径工作簿,循环遍历工作表名称,根据表格单元内内容锁定工作表名称,然后进行操作....
2022-10-18 07:10
zxh48911805
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2022-7-9
收藏
得分:0 
可以给个代码吗谢谢
2022-10-18 08:41
约定的童话
Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20
等 级:版主
威 望:56
帖 子:246
专家分:1442
注 册: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
快速回复:VB6读取Excel数据生成文件
数据加载中...
 
   



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

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