excel을 이용하여 pdm표 구조 생성

1789 단어
1단계: Excel 테이블 구조 정리(지정한 위치에 놓기)
2단계: 스크립트를 이용하여 pdm 생성
스크립트는 다음과 같습니다.
Option Explicit

Dim mdl ' the current model
Set mdl = ActiveModel
If (mdl Is Nothing) Then
   MsgBox "There is no Active Model"
End If

Dim HaveExcel
Dim RQ
RQ = vbYes 'MsgBox("Is Excel Installed on your machine ?", vbYesNo + vbInformation, "Confirmation")
If RQ = vbYes Then
   HaveExcel = True
   'Open & Create Excel Document
   Dim x1  
   Set x1 = CreateObject("Excel.Application")
   x1.Application.Visible = True
   x1.Workbooks.Open "C:\jsxm.xlsx"'excel 
   x1.Workbooks(1).Worksheets("Sheet1").Activate' sheet
Else
   HaveExcel = False
End If




a x1, mdl

sub a(x1, mdl)
dim rwIndex
dim tableName
dim colname
dim table
dim col
dim count

dim  shtIdx
for shtIdx=1 to x1.Workbooks(1).Worksheets.Count	
	on error Resume Next

	With x1.Workbooks(1).Worksheets(shtIdx)
		If .Cells(1, 1).Value = "if_t_buildProject" Then' 
			count = count + 1       	        
			set table = mdl.Tables.CreateNew
			table.Code = .Cells(1, 1).Value' ( excel )
			table.Name = .Cells(1, 2).Value' 
			table.Comment = .Cells(1, 3).Value' 
		
			For rwIndex = 3 To 255'     				
				If .Cells(rwIndex, 3).Value <> "" Then' 
					set col = table.Columns.CreateNew
					col.Name = .Cells(rwIndex, 1).Value' 
					col.Code = .Cells(rwIndex, 2).Value' 
					col.Comment = .Cells(rwIndex, 8).Value' 
					col.DataType =  .Cells(rwIndex, 3).Value' 
						                         
        End If
      Next
    End If
  End With


Next

x1.Application.Quit
Set x1=Nothing

MsgBox "  " + CStr(count), vbOK + vbInformation, " "
End sub

자원 주소

좋은 웹페이지 즐겨찾기