• 回复
  • 收藏
  • 点赞
  • 分享
  • 发新帖

PADS2007/logic怎样转材料清单?BOM

请问各位PADS2007/logic怎样转成BOM,可以转成Excel文档格式吗?
还要麻烦各位具体说一下怎么操做,谢谢各位!
全部回复(1)
正序查看
倒序查看
rosen0594
LV.1
2
2009-10-16 16:01
'This script has been generated by PowerPCB's VB Script Wizard on 2006-6-1 下午 12:24:43
'It will create reports in Microsoft Excel Format.
'You can use the following code as a skeleton for your own VB scripts
Dim fname As String

Sub Main
   fname = ActiveDocument
   If fname = "" Then
       fname = "Untitled"
   End If
   tempFile = DefaultFilePath & "\temp.txt"
   Open tempFile For Output As #1
   Print #1, Space(1); "Assembly Option Part List Report for "; fname; " on "; Now
   Print #1

   StatusBarText = "Generating report..."
   For Each opt in ActiveDocument.AssemblyOptions
       Print #1
       Print #1, Space(1); "Assembly Option: "; GetOptName(opt)
       Print #1
       For Each part in opt.Components
           Print #1, vbTab; part.Name & vbTab & AttrVal(part, "Value")
       Next part
   Next opt

   StatusBarText = ""
   Close #1
   ExportToExcel
End Sub

Function GetOptName(opt As Object)
   GetOptName = Left(opt.Name, Len(opt.Name) - (Len(ActiveDocument.Name) + 1))
End Function

Function AttrVal (obj As Object, nm As String)
   AttrVal = IIf(obj.Attributes(nm) Is Nothing, "", obj.Attributes(nm))
End Function

Sub ExportToExcel
   FillClipboard
   Dim xl As Object
   On Error Resume Next
   Set xl = GetObject(,"Excel.Application")
   On Error GoTo ExcelError    ' Enable error trapping.
   If xl Is Nothing Then
       Set xl = CreateObject("Excel.Application")
   End If
   xl.Visible = True
   xl.Workbooks.Add
   xl.ActiveSheet.Paste
   xl.Range("A1").Select
   'Format bold lines
   For Each row In xl.ActiveSheet.UsedRange.Rows
       If Left(row.Cells(1), 1) = Space(1) Then
           row.Font.bold = True
       End If
   Next
   On Error GoTo 0 ' Disable error trapping.
   Exit Sub  

ExcelError:
   MsgBox Err.Description, vbExclamation, "Error Running Excel"
   On Error GoTo 0 ' Disable error trapping.  
   Exit Sub
End Sub

Sub FillClipboard
   StatusBarText = "Export Data To Clipboard..."
   ' Load whole file to string variable  
   tempFile = DefaultFilePath & "\temp.txt"
   Open tempFile For Input As #1
   L = LOF(1)
   AllData$ = Input$(L,1)
   Close #1
   'Copy whole data to clipboard
   Clipboard AllData$
   Kill tempFile
   StatusBarText = ""
End Sub
0
回复