M
MattC
Hi,
I'm trying to use the Office PIA to access MSGraph.
I've placed Microsoft.Office.Interop.Graph.dll in with my C# code and added
it as a reference to the project.
The code compiles, (although what is will do yet???) but when run I am
presented with an Unauthorized Access Exception.
Do I need to give the ASPNET user account access to create the MSGraph COM
object. If so how, does this require DComCnfg??
Below is my code.
Any help or advice greatly appreciated!
TIA
MattC
using System.Runtime.InteropServices;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
MSGraph.Application g = new MSGraph.GlobalClass().Application;
MSGraph.Chart c = g.Chart();
c.ChartArea.Font.Size = 8;
c.Application.Update();
c.ChartType = MSGraph.XlChartType.xl3DBarClustered;
c.HasTitle = true;
c.ChartTitle.Caption = "This is a Test";
c.ChartTitle.Font.Size = 12;
MSGraph.DataSheet ds = g.Application.DataSheet;
ds.Cells.Clear();
ds.Cells[2, 1] = "Widgets";
ds.Cells[3, 1] = "Gadgets";
ds.Cells[4, 1] = "Gizmos";
ds.Cells[1, 2] = "1999";
ds.Cells[1, 3] = "2000";
int row;
int col;
Random r = new Random();
for(row = 2; row <= 4; row++)
for(col = 2; col <= 3; col++)
ds.Cells[row, col] = r.Next(100000);
g.Application.Update(); //Update the changes
g.Application.Quit(); //and deactivate the chart.
I'm trying to use the Office PIA to access MSGraph.
I've placed Microsoft.Office.Interop.Graph.dll in with my C# code and added
it as a reference to the project.
The code compiles, (although what is will do yet???) but when run I am
presented with an Unauthorized Access Exception.
Do I need to give the ASPNET user account access to create the MSGraph COM
object. If so how, does this require DComCnfg??
Below is my code.
Any help or advice greatly appreciated!
TIA
MattC
using System.Runtime.InteropServices;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
MSGraph.Application g = new MSGraph.GlobalClass().Application;
MSGraph.Chart c = g.Chart();
c.ChartArea.Font.Size = 8;
c.Application.Update();
c.ChartType = MSGraph.XlChartType.xl3DBarClustered;
c.HasTitle = true;
c.ChartTitle.Caption = "This is a Test";
c.ChartTitle.Font.Size = 12;
MSGraph.DataSheet ds = g.Application.DataSheet;
ds.Cells.Clear();
ds.Cells[2, 1] = "Widgets";
ds.Cells[3, 1] = "Gadgets";
ds.Cells[4, 1] = "Gizmos";
ds.Cells[1, 2] = "1999";
ds.Cells[1, 3] = "2000";
int row;
int col;
Random r = new Random();
for(row = 2; row <= 4; row++)
for(col = 2; col <= 3; col++)
ds.Cells[row, col] = r.Next(100000);
g.Application.Update(); //Update the changes
g.Application.Quit(); //and deactivate the chart.