S
Steve
Hi. I am trying to import an aspx file that converts to an excel file, then I
save the excel file and transfer outline level 1 %complete from project to
the excel file. It will not work however, it either crashes or gives me no
update or excel loads but does not show the workbook. Here is my code: [the
web address and filepath you see are not the correct ones, but that shouldn't
matter]
Sub SaveWebData()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://www.data.com/ExportProjectList.aspx" 'load web
page
While IE.busy
DoEvents 'wait until IE is done loading page.
Wend
IE.Visible = False
'ie is now done loading the page
End Sub
Sub UpdatePercentComplete()
Dim ExcelSheet As Excel.Workbook
Dim xlRange As Excel.Range
Dim Tsk As Task
Set ExcelSheet = GetObject("C:\Excel.xls")
ExcelSheet.Application.Visible = True
Set xlRange = ExcelSheet.Worksheets("FileName").Range("K2")
ExcelSheet.Application.ScreenUpdating = False
For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then
If Tsk.OutlineLevel = 1 Then
With xlRange
.Range("K2") = (Tsk.PercentComplete / 100)
End With
Set xlRange = xlRange.Offset(1, 0)
End If
End If
Next Tsk
ExcelSheet.Application.ScreenUpdating = True
ExcelSheet.Save
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
End Sub
Sub CostReport()
Dim StartTime As Date
StartTime = Now
SaveWebData
Do While DateDiff("s", StartTime, Now) < 15
Loop
UpdatePercentComplete
End Sub
The Loop in this routine gives the user enough time to click save from the
aspx file and click yes if there is an existing file with the same name.
save the excel file and transfer outline level 1 %complete from project to
the excel file. It will not work however, it either crashes or gives me no
update or excel loads but does not show the workbook. Here is my code: [the
web address and filepath you see are not the correct ones, but that shouldn't
matter]
Sub SaveWebData()
Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")
IE.Navigate "http://www.data.com/ExportProjectList.aspx" 'load web
page
While IE.busy
DoEvents 'wait until IE is done loading page.
Wend
IE.Visible = False
'ie is now done loading the page
End Sub
Sub UpdatePercentComplete()
Dim ExcelSheet As Excel.Workbook
Dim xlRange As Excel.Range
Dim Tsk As Task
Set ExcelSheet = GetObject("C:\Excel.xls")
ExcelSheet.Application.Visible = True
Set xlRange = ExcelSheet.Worksheets("FileName").Range("K2")
ExcelSheet.Application.ScreenUpdating = False
For Each Tsk In ActiveProject.Tasks
If Not Tsk Is Nothing Then
If Tsk.OutlineLevel = 1 Then
With xlRange
.Range("K2") = (Tsk.PercentComplete / 100)
End With
Set xlRange = xlRange.Offset(1, 0)
End If
End If
Next Tsk
ExcelSheet.Application.ScreenUpdating = True
ExcelSheet.Save
ExcelSheet.Application.Quit
Set ExcelSheet = Nothing
End Sub
Sub CostReport()
Dim StartTime As Date
StartTime = Now
SaveWebData
Do While DateDiff("s", StartTime, Now) < 15
Loop
UpdatePercentComplete
End Sub
The Loop in this routine gives the user enough time to click save from the
aspx file and click yes if there is an existing file with the same name.