P
Peter Darmody
I have written code in Microsoft Project which creates an
excel workbook and then creates a report in excel from
information in Project.
When I have finished the report I want to sort it on a
certain field, but I can't get the Sort to work.
I have had various errors but the latest is
"application or object defined error"
I have set up the code like this (remembering that this is
written in a module in Microsoft project)
- Check to see if excel is running with
Set MyXL = GetObject(, "Excel.Application")
and if this produces an error I start Excel with
Set MyXL = CreateObject("Excel.Application")
I then create a new workbook with
MyXL.Application.Workbooks.Add
outbook = MyXL.Application.ActiveWorkbook.Name
and then proceed to fill the report using:
With MyXL.Application.Workbooks(outbook).ActiveSheet
<fill report with data>
While still within the WITH statement I have tried
to sort the report with:
..Range("A1:L" & CStr(Rownum - 1)).Sort Key1:=Range("K2"),
Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, Orientation:=xlTopToBottom
But it won't work.
Any suggestions??
Peter
excel workbook and then creates a report in excel from
information in Project.
When I have finished the report I want to sort it on a
certain field, but I can't get the Sort to work.
I have had various errors but the latest is
"application or object defined error"
I have set up the code like this (remembering that this is
written in a module in Microsoft project)
- Check to see if excel is running with
Set MyXL = GetObject(, "Excel.Application")
and if this produces an error I start Excel with
Set MyXL = CreateObject("Excel.Application")
I then create a new workbook with
MyXL.Application.Workbooks.Add
outbook = MyXL.Application.ActiveWorkbook.Name
and then proceed to fill the report using:
With MyXL.Application.Workbooks(outbook).ActiveSheet
<fill report with data>
While still within the WITH statement I have tried
to sort the report with:
..Range("A1:L" & CStr(Rownum - 1)).Sort Key1:=Range("K2"),
Order1:=xlAscending, Header:=xlGuess, OrderCustom:=1,
MatchCase:=False, Orientation:=xlTopToBottom
But it won't work.
Any suggestions??
Peter