R
RevKev
Hello All,
I am trying to take a custom view and copy that to EXCEL. The View has a
simple table on the left, which I can programatically write to EXCEL.
However, the table on the left (TimeScale) which has Cost and Work is giving
me a lot of problems. I cannot seem to figure out how to copy and paste into
EXCEL.
If I target the top, left cell I get an error that there is nothing in the
clipboard. Likewise if I just try to get a few cells, the table turns blue
as if it has been selected, however nothing will copy over.... here is what
I have;
--------------------------------------------------------------------------------
Dim xlRow As Excel.Range
Dim xlCol As Excel.Range
Sub TrasferTimescaleData()
Const intervalType As Integer = pjTimescaleWeeks
Const dataType As Integer = pjWork
Const dataCost As Integer = pjCost
'Link to Excel
Dim Xl As Excel.Application
Dim xlSheet As Excel.Worksheet
Dim xlBook As Excel.Workbook
Set Xl = CreateObject("Excel.Application")
Set Xl = New Excel.Application
Set xlBook = Xl.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
xlSheet.Name = "pj"
'Set first cell
Set xlRow = Xl.ActiveCell
'Copy Left Table
'SelectRange 3, 4
'xlSheet.Paste xlRow
'SelectResourceColumn Column:="Name", Additional:=2
'EditCopy
'xlSheet.Paste
'Transfer Table Headings
Dim i As Integer
Dim Heading As String
For i = 1 To ActiveSelection.FieldNameList.count
xlSheet.Cells(1, i) = ActiveSelection.FieldNameList(i)
Next
'Copy Time Scale Data
Dim TSValues As TimeScaleValues
Dim noColumns As Integer, startCol As Integer
TimescaleEdit intervalType, intervalType
DetailStylesRemoveAll
DetailStylesAdd Item:=dataType
DetailStylesAdd Item:=dataCost
Set TSValues =
ActiveProject.ProjectSummaryTask.TimeScaleData(ActiveProject.ProjectStart,
ActiveProject.ProjectFinish, intervalType)
noColumns = TSValues.count
PaneNext
SelectTimescaleRange Row:=1, StartTime:="Sun 10/1/06", Width:=5, Height:=8
'Tansfer Timescale Dates
Dim TSV As TimeScaleValue
i = 0
For Each TSV In TSValues
i = i + 1
xlSheet.Cells(1, 1) = Format(TSV.StartDate, "mm/dd/yy")
Next
Xl.Visible = True
EditCopy
xlSheet.Paste
End Sub
I am trying to take a custom view and copy that to EXCEL. The View has a
simple table on the left, which I can programatically write to EXCEL.
However, the table on the left (TimeScale) which has Cost and Work is giving
me a lot of problems. I cannot seem to figure out how to copy and paste into
EXCEL.
If I target the top, left cell I get an error that there is nothing in the
clipboard. Likewise if I just try to get a few cells, the table turns blue
as if it has been selected, however nothing will copy over.... here is what
I have;
--------------------------------------------------------------------------------
Dim xlRow As Excel.Range
Dim xlCol As Excel.Range
Sub TrasferTimescaleData()
Const intervalType As Integer = pjTimescaleWeeks
Const dataType As Integer = pjWork
Const dataCost As Integer = pjCost
'Link to Excel
Dim Xl As Excel.Application
Dim xlSheet As Excel.Worksheet
Dim xlBook As Excel.Workbook
Set Xl = CreateObject("Excel.Application")
Set Xl = New Excel.Application
Set xlBook = Xl.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
xlSheet.Name = "pj"
'Set first cell
Set xlRow = Xl.ActiveCell
'Copy Left Table
'SelectRange 3, 4
'xlSheet.Paste xlRow
'SelectResourceColumn Column:="Name", Additional:=2
'EditCopy
'xlSheet.Paste
'Transfer Table Headings
Dim i As Integer
Dim Heading As String
For i = 1 To ActiveSelection.FieldNameList.count
xlSheet.Cells(1, i) = ActiveSelection.FieldNameList(i)
Next
'Copy Time Scale Data
Dim TSValues As TimeScaleValues
Dim noColumns As Integer, startCol As Integer
TimescaleEdit intervalType, intervalType
DetailStylesRemoveAll
DetailStylesAdd Item:=dataType
DetailStylesAdd Item:=dataCost
Set TSValues =
ActiveProject.ProjectSummaryTask.TimeScaleData(ActiveProject.ProjectStart,
ActiveProject.ProjectFinish, intervalType)
noColumns = TSValues.count
PaneNext
SelectTimescaleRange Row:=1, StartTime:="Sun 10/1/06", Width:=5, Height:=8
'Tansfer Timescale Dates
Dim TSV As TimeScaleValue
i = 0
For Each TSV In TSValues
i = i + 1
xlSheet.Cells(1, 1) = Format(TSV.StartDate, "mm/dd/yy")
Next
Xl.Visible = True
EditCopy
xlSheet.Paste
End Sub