|
|
Hãy đăng nhập để có nhiều chức năng hữu dụng hơn và xem ảnh rõ hơn!
Bạn phải đăng nhập để xem được nội dung, nếu bạn chưa có tài khoản? hãy Đăng ký mới
x
Mình tìm được code VBA chuyển dữ liệu từ exel sang Ms project (cũng không rõ đúng ko nữa, tiếng anh nhập nhèm), nhưng không biết tích hợp như thế nào
(tạo nút chỉ cần ấn là tự động chuyển).
Nếu code là đúngthì các bạn tạo giúp mình form trên exel để chuyển sang project 2003 nhé (giải thích rõ thì càng tốt, để tiện chỉnh sửa lại - nếu code không đúng thì mình có thể dựa vào pm dự toán chuyển qua cũng được, có thì sau này tiên hơn ^^ - thanks)
Thanks
Link: http://www.vbaexpress.com/forum/ ... 23e92e74c3f13b36423
- Option Explicit
- Sub Add_Data_Project()
- 'Add a reference to Microsoft Project x.x Object Library
- 'in the VB-editor through the command Tools | References..
- 'The x.x stands for version like 11.0 or previously.
- Dim wbBook As Workbook
- Dim wsSheet As Worksheet
- Dim stTeammember As String, stTask As String
- Dim dtStartDate As Date
- Dim lnTime As Long
- Set wbBook = ThisWorkbook
- Set wsSheet = wbBook.Worksheets(1)
- 'Populate the variables with values from the worksheet.
- With wsSheet
- stTeammember = .Range("D5").Value
- stTask = .Range("E5").Value
- dtStartDate = .Range("F5").Value
- lnTime = .Range("G5").Value
- End With
- 'Instantiate and open MS Project and the project.
- Dim prApp As MSProject.Application
- Dim prProject As MSProject.Project
- Set prApp = New MSProject.Application
- prApp.FileOpen "c:\VBAX.mpp"
- Set prProject = prApp.ActiveProject
- 'Add task and other wanted information to the project.
- With prProject
- .Tasks.Add stTask
- With .Tasks(stTask)
- .Duration = lnTime & " days"
- .ResourceNames = stTeammember
- .Start = dtStartDate
- End With
- End With
- 'Save the project and close MS Project.
- With prApp
- .FileSave
- .Quit
- End With
- MsgBox "The project VBAX has successfully been updated!", vbInformation
- 'Release objects from memory.
- Set prProject = Nothing
- Set prApp = Nothing
- End Sub
Sao chép mã
|
|