|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
本身VBA程序运行后是没有问题的,但是封装成DLL文件后出现错误91是怎么回事?求大神帮忙解决
下述为VBA程序- Sub 批量转化()
- Application.ScreenUpdating = False
- Application.EnableCancelKey = xlDisabled
- Dim yyy As String, xxx As String, n As Long, Last As Long
- yyy = "电气打包-巨人通力7A箱清单模板.xlsm"
- xxx = ActiveWorkbook.Name
- Last = ActiveWorkbook.Sheets("配置").Range("D1").Value
-
- Workbooks.Open Filename:=ThisWorkbook.Path & "" & yyy
- Windows(xxx).Activate
- ActiveWorkbook.Sheets("配置").Select
- Range("E4:I103").Select
- Selection.ClearContents
- ActiveWorkbook.Sheets("配置").Range("D2").Value = 1
- Sheets("BOM清单明细").Visible = -1
- Sheets("装箱单SAP").Visible = -1
- Sheets("执行结果").Visible = -1
-
- For n = 1 To Last
- Windows(xxx).Activate
- Sheets("配置").Select
- Sheets("配置").Range("D2").Value = n
- Sheets("配置").Range("E2:I2").Select
- Selection.Copy
- Sheets("配置").Range("E" & 3 + n).Select
- Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
- :=False, Transpose:=False
-
-
- Windows(xxx).Activate
- Sheets("BOM清单明细").Select
- Application.CutCopyMode = False
- Selection.Copy
- Windows(yyy).Activate
- Sheets("BOM清单明细").Visible = -1
- Sheets("BOM清单明细").Select
- Range("A1").Select
- ActiveSheet.Paste
-
- Windows(xxx).Activate
- Sheets("装箱单SAP").Select
- Application.CutCopyMode = False
- Selection.Copy
- Windows(yyy).Activate
- Sheets("装箱单SAP").Visible = -1
- Sheets("装箱单SAP").Select
- Range("A1").Select
- ActiveSheet.Paste
-
- Windows(xxx).Activate
- Sheets("执行结果").Select
- Application.CutCopyMode = False
- Selection.Copy
- Windows(yyy).Activate
- Sheets("执行结果").Visible = -1
- Sheets("执行结果").Select
- Range("A1").Select
- ActiveSheet.Paste
- If Sheets("执行结果").Range("A1") = "" Then
- Sheets("执行结果").Visible = 0
- End If
-
- Windows(yyy).Activate
- Sheets("BOM清单明细").Select
- Application.DisplayAlerts = False
- If Sheets("执行结果").Visible = 0 Then
- yyy = Sheets("BOM清单明细").[C2] & ".xlsx"
- Else
- yyy = Sheets("BOM清单明细").[C2] & "错误.xlsx"
- End If
- ActiveWorkbook.SaveAs Filename:=ThisWorkbook.Path & "" & yyy, FileFormat:= _
- xlOpenXMLWorkbook, CreateBackup:=False
- Application.DisplayAlerts = True
- Next n
- Windows(yyy).Activate
- ActiveWorkbook.Close False
-
- Windows(xxx).Activate
- Sheets("配置").Select
- ActiveWorkbook.Sheets("配置").Range("D2").Value = 1
- Sheets("BOM清单明细").Visible = 2
- Sheets("装箱单SAP").Visible = 2
- Sheets("执行结果").Visible = 2
- Application.ScreenUpdating = True
- End Sub
复制代码
|
|