This is unlikely to work as the field 'Missing' is never defined or
initialised.

On 25 Dec 2008, 15:20, "Esoimeme George" <[email protected]>
wrote:
> Hi,
> I have Visual Studio 2005 and MicrosoftExcel2003.
> Can you run this, though , it is saying I do not have
> Microsoft.Office.Interop.Excelon  my pc.
>
> private void button1_Click(object sender, System.EventArgs e)
> {
>        Excel.Application oXL;
>        Excel._Workbook oWB;
>        Excel._Worksheet oSheet;
>        Excel.Range oRng;
>
>         try
>         {
>                 //StartExceland get Application object.
>                 oXL = newExcel.Application();
>                 oXL.Visible = true;
>
>                 //Get a new workbook.
>                 oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
>                 oSheet = (Excel._Worksheet)oWB.ActiveSheet;
>
>                 //Add table headers going cell by cell.
>                 oSheet.Cells[1, 1] = "First Name";
>                 oSheet.Cells[1, 2] = "Last Name";
>                 oSheet.Cells[1, 3] = "Full Name";
>                 oSheet.Cells[1, 4] = "Salary";
>
>                 //Format A1:D1 as bold, vertical alignment = center.
>                 oSheet.get_Range("A1", "D1").Font.Bold = true;
>                 oSheet.get_Range("A1", "D1").VerticalAlignment =
>                        Excel.XlVAlign.xlVAlignCenter;
>
>                 // Create an array to multiple values at once.
>                 string[,] saNames = new string[5,2];
>
>                 saNames[ 0, 0] = "John";
>                 saNames[ 0, 1] = "Smith";
>                 saNames[ 1, 0] = "Tom";
>                 saNames[ 1, 1] = "Brown";
>                 saNames[ 2, 0] = "Sue";
>                 saNames[ 2, 1] = "Thomas";
>                 saNames[ 3, 0] = "Jane";
>                 saNames[ 3, 1] = "Jones";
>                 saNames[ 4, 0] = "Adam";
>                 saNames[ 4, 1] = "Johnson";
>
>                 //Fill A2:B6 with an array of values (First and Last Names).
>                 oSheet.get_Range("A2", "B6").Value2 = saNames;
>
>                 //Fill C2:C6 with a relative formula (=A2 & " " & B2).
>                 oRng = oSheet.get_Range("C2", "C6");
>                 oRng.Formula = "=A2 & \" \" & B2";
>
>                 //Fill D2:D6 with a formula(=RAND()*100000) and apply format.
>                 oRng = oSheet.get_Range("D2", "D6");
>                 oRng.Formula = "=RAND()*100000";
>                 oRng.NumberFormat = "$0.00";
>
>                 //AutoFit columns A:D.
>                 oRng = oSheet.get_Range("A1", "D1");
>                 oRng.EntireColumn.AutoFit();
>
>                 //Manipulate a variable number of columns for Quarterly Sales 
> Data.
>                 DisplayQuarterlySales(oSheet);
>
>                 //Make sureExcelis visible and give the user control
>                 //of MicrosoftExcel'slifetime.
>                 oXL.Visible = true;
>                 oXL.UserControl = true;
>         }
>         catch( Exception theException )
>         {
>                 String errorMessage;
>                 errorMessage = "Error: ";
>                 errorMessage = String.Concat( errorMessage, 
> theException.Message );
>                 errorMessage = String.Concat( errorMessage, " Line: " );
>                 errorMessage = String.Concat( errorMessage, 
> theException.Source );
>
>                 MessageBox.Show( errorMessage, "Error" );
>         }
>
> }
>
> private void DisplayQuarterlySales(Excel._Worksheet oWS)
> {
>        Excel._Workbook oWB;
>        Excel.Series oSeries;
>        Excel.Range oResizeRange;
>        Excel._Chart oChart;
>         String sMsg;
>         int iNumQtrs;
>
>         //Determine how many quarters to display data for.
>         for( iNumQtrs = 4; iNumQtrs >= 2; iNumQtrs--)
>         {
>                 sMsg = "Enter sales data for ";
>                 sMsg = String.Concat( sMsg, iNumQtrs );
>                 sMsg = String.Concat( sMsg, " quarter(s)?");
>
>                 DialogResult iRet = MessageBox.Show( sMsg, "Quarterly Sales?",
>                         MessageBoxButtons.YesNo );
>                 if (iRet == DialogResult.Yes)
>                         break;
>         }
>
>         sMsg = "Displaying data for ";
>         sMsg = String.Concat( sMsg, iNumQtrs );
>         sMsg = String.Concat( sMsg, " quarter(s)." );
>
>         MessageBox.Show( sMsg, "Quarterly Sales" );
>
>         //Starting at E1, fill headers for the number of columns selected.
>         oResizeRange = oWS.get_Range("E1", "E1").get_Resize( Missing.Value, 
> iNumQtrs);
>         oResizeRange.Formula = "=\"Q\" & COLUMN()-4 & CHAR(10) & \"Sales\"";
>
>         //Change the Orientation and WrapText properties for the headers.
>         oResizeRange.Orientation = 38;
>         oResizeRange.WrapText = true;
>
>         //Fill the interior color of the headers.
>         oResizeRange.Interior.ColorIndex = 36;
>
>         //Fill the columns with a formula and apply a number format.
>         oResizeRange = oWS.get_Range("E2", "E6").get_Resize( Missing.Value, 
> iNumQtrs);
>         oResizeRange.Formula = "=RAND()*100";
>         oResizeRange.NumberFormat = "$0.00";
>
>         //Apply borders to the Sales data and headers.
>         oResizeRange = oWS.get_Range("E1", "E6").get_Resize( Missing.Value, 
> iNumQtrs);
>         oResizeRange.Borders.Weight =Excel.XlBorderWeight.xlThin;
>
>         //Add a Totals formula for the sales data and apply a border.
>         oResizeRange = oWS.get_Range("E8", "E8").get_Resize( Missing.Value, 
> iNumQtrs);
>         oResizeRange.Formula = "=SUM(E2:E6)";
>         oResizeRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom 
> ).LineStyle
>                 =Excel.XlLineStyle.xlDouble;
>         oResizeRange.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom 
> ).Weight
>                 =Excel.XlBorderWeight.xlThick;
>
>         //Add a Chart for the selected data.
>         oWB = (Excel._Workbook)oWS.Parent;
>         oChart = (Excel._Chart)oWB.Charts.Add( Missing.Value, Missing.Value,
>                 Missing.Value, Missing.Value );
>
>         //Use the ChartWizard to create a new chart from the selected data.
>         oResizeRange = oWS.get_Range("E2:E6", Missing.Value ).get_Resize(
>                 Missing.Value, iNumQtrs);
>         oChart.ChartWizard( oResizeRange,Excel.XlChartType.xl3DColumn, 
> Missing.Value,
>                Excel.XlRowCol.xlColumns, Missing.Value, Missing.Value, 
> Missing.Value,
>                 Missing.Value, Missing.Value, Missing.Value, Missing.Value );
>         oSeries = (Excel.Series)oChart.SeriesCollection(1);
>         oSeries.XValues = oWS.get_Range("A2", "A6");
>         for( int iRet = 1; iRet <= iNumQtrs; iRet++)
>         {
>                 oSeries = (Excel.Series)oChart.SeriesCollection(iRet);
>                 String seriesName;
>                 seriesName = "=\"Q";
>                 seriesName = String.Concat( seriesName, iRet );
>                 seriesName = String.Concat( seriesName, "\"" );
>                 oSeries.Name = seriesName;
>         }                                                                     
>                                          
>
>         oChart.Location(Excel.XlChartLocation.xlLocationAsObject, oWS.Name );
>
>         //Move the chart so as not to cover your data.
>         oResizeRange = (Excel.Range)oWS.Rows.get_Item(10, Missing.Value );
>         oWS.Shapes.Item("Chart 1").Top = (float)(double)oResizeRange.Top;
>         oResizeRange = (Excel.Range)oWS.Columns.get_Item(2, Missing.Value );
>         oWS.Shapes.Item("Chart 1").Left = (float)(double)oResizeRange.Left;
>
> }
>
> On 12/25/08, DotNetDevelopment group <[email protected]> wrote:
>
>
>
>
>
>
>
> > DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
> > Services,.
> > NET Remoting
> > [email protected]
>
> >http://groups.google.com/group/DotNetDevelopment?hl=en
>
> > Today's most active topics:
>
> > * Return Vowels in C# - 5 new
> >  http://groups.google.com/group/DotNetDevelopment/t/a83be1b373ac1f16?h...
> > * Not Getting Any Break Point in VWD to be hit when compiling - 4 new
> >  http://groups.google.com/group/DotNetDevelopment/t/4c741a21979b834f?h...
> > * A network-related or instance-specific error occurred - 3 new
> >  http://groups.google.com/group/DotNetDevelopment/t/5aa9cbe12c8ac18d?h...
> > * Addin For removing comments - 2 new
> >  http://groups.google.com/group/DotNetDevelopment/t/4ef32466769d3d2f?h...
> > * unable to connect sql server 2005 - 2 new
> >  http://groups.google.com/group/DotNetDevelopment/t/7e6547728e3640b8?h...
>
> > Active Topics
> > -------------
>
> > A network-related or instance-specific error occurred - 3 new
> > -------------------------------------------------------------
> > it is an windows application it is working in one of the clients same
> > connection string, and in another system the Microsoft Sql Server is not at
> > all opening, we have restarted the services, but of no use, Please can
> > anybody
> > tell me wat the problem is. Thanks On Wed, Dec 24, 2008 at 12:53 AM, The_
> > Fruitman - Tues, Dec 23 2008 10:26 pm
> > 3 messages , 3 authors
> >http://groups.google.com/group/DotNetDevelopment/t/5aa9cbe12c8ac18d?h...
>
> > Not Getting Any Break Point in VWD to be hit when compiling - 4 new
> > -------------------------------------------------------------------
> > all dear friends i got the problem that i want to debug my web app in step
> > by
> > step debugging mode, currently i am using VS2005 (.Net 2.0), i searched alot
> > but found nothing special, if any body gets it solved and replied to me for
> > him/her/them i shall be very pleased - Wed, Dec 24 2008 12:53 am
> > 4 messages , 3 authors
> >http://groups.google.com/group/DotNetDevelopment/t/4c741a21979b834f?h...
>
> > Addin For removing comments - 2 new
> > -----------------------------------
> > heres a good add in...backspace key. highlight and delete key. space bar
> > space
> > bar space bar - Wed, Dec 24 2008 1:25 am
> > 2 messages , 2 authors
> >http://groups.google.com/group/DotNetDevelopment/t/4ef32466769d3d2f?h...
>
> > unable to connect sql server 2005 - 2 new
> > -----------------------------------------
> > hi, I am using visual studio 2005 to create asp.net application . but I
> > could
> > connect to sql server 2005. The error is as follows: "when connecting to sql
> > server 2005,this failure may be caused by the fact that under the default
> > settings sql server does n't allow remote connections." Please help me to
> > solve the problem. - Tues, Dec 23 2008 11:41 pm
> > 2 messages , 2 authors
> >http://groups.google.com/group/DotNetDevelopment/t/7e6547728e3640b8?h...
>
> > Problem while launching an Application through windows service,
> > Process.start()
> >  gives an error message - 1 new
> > -------------------------------
> > An eventing service (Project server event handler) is running on windows
> > 2003
> > server. This service is running under the user "Network Service". This
> > eventing service triggers event handlers against certain events performed on
> > Microsoft Project. The problem occurs when my event handler tries launching
> > an
> > application under the user - Tues, Dec 23 2008 9:46 pm
> > 1 message, 1 author
> >http://groups.google.com/group/DotNetDevelopment/t/3457b58e984f3645?h...
>
> > Help with ASP files (work for just a standalone computer vice a server) - 2
> > new
> > ---
> > Hello! After Googling for weeks, I found this site on how to create an
> > organization chart using the data stored in an Access database: [link].
> > There
> > are only 4 files (OrganizationCreate.asp, OrganizationOpen.asp, - Wed, Dec
> > 24
> > 2008 5:03 am
> > 2 messages , 2 authors
> >http://groups.google.com/group/DotNetDevelopment/t/d3cd7d9ff45bc4e2?h...
>
> > Accessing database from network - 2 new
> > ---------------------------------------
> > Hi guys, I need help for following issue. I got a project of VB.net with
> > Access database on suppose 'x' pc on my company network. I want to run it's
> > exe on network from 'y' pc on the same network. both the pc are connected
> > through LAN. Since the project is on x pc it runs fine on it, but when I run
> > the same exe on y (on My Network - Wed, Dec 24 2008 1:22 am
> > 2 messages , 2 authors
> >http://groups.google.com/group/DotNetDevelopment/t/728922063109d614?h...
>
> > Audio Player control in .NET - reg - 1 new
> > ------------------------------------------
> > ah! i forgot mention that there is a need to grab audio from various input
> > devices... - Tues, Dec 23 2008 9:17 pm
> > 1 message, 1 author
> >http://groups.google.com/group/DotNetDevelopment/t/1b99c66fffcfe797?h...
>
> > Editable textboxes within a datagrid row - 2 new
> > ------------------------------------------------
> > I'm using a great book "ASP.NET Data Web Controls" by Scott Mitchell. In
> > this
> > book I see a screenshot of a datagrid that when the "Edit" hyperlink button
> > is
> > pressed all the editable fields turn into textboxes. I wondering how to
> > accomplish this. Also how do you allow only one row to be chosen? When I hit
> > my edit - Wed, Dec 24 2008 7:55 am
> > 2 messages , 2 authors
> >http://groups.google.com/group/DotNetDevelopment/t/1cd488dfd9c68ce6?h...
>
> > Return Vowels in C# - 5 new
> > ---------------------------
> > Hi Guys, The easy way for beginners to count vowels in a string is using
> > System; using System.Collections.Generic; using System.Text; namespace
> > ConsoleApplication3 { class Program { static void Main(string[] args) {
> > Console.WriteLine("Enter the string"); - Wed, Dec 24 2008 3:30 pm
> > 5 messages , 3 authors
> >http://groups.google.com/group/DotNetDevelopment/t/a83be1b373ac1f16?h...
>
> > How to write range(cells(1,1),cells(5,6)).select in vb.net? - 1 new
> > -------------------------------------------------------------------
> > I am sorry I don't quite follow your suggestion, Ritesh. Could you please
> > explain it little bit? Thanks for your willingness to help. Musa Biralo -
> > Wed,
> > Dec 24 2008 6:27 pm
> > 1 message, 1 author
> >http://groups.google.com/group/DotNetDevelopment/t/2810e6f4a0dc9dc8?h...
>
> > Registration of Remote Sql Server 2000 - 1 new
> > ----------------------------------------------
> > Hello all in here... i have a install sql server 2000 on remote computer
> > which
> > have a live ip. e.g 50.13.2.2 . i have registered sql server 2000 on it..
> > now
> > when i want to registered this live ip sql server 2000 on client system. it
> > give me error .. some time "Time out Exception" and some time - Wed, Dec 24
> > 2008 9:06 pm
> > 1 message, 1 author
> >http://groups.google.com/group/DotNetDevelopment/t/79d89804fdc9e2c7?h...
>
> > How to update StatusStrip from class to form? - 1 new
> > -----------------------------------------------------
> > I don't how Arun's solution worked. It was not working for me. What I did
> > was
> > like below. Public Class Form1 '' Windows Form Designer generated code is
> > hidden Private WithEvents c1 As class1 Private Sub UpdateStatusStrip(ByVal
> > msg
> > As String) Handles c1.UpdateStatus Label1.Text = msg - Wed, Dec 24 2008 8:12
> > pm
> > 1 message, 1 author
> >http://groups.google.com/group/DotNetDevelopment/t/63ca8ac81e3419d7?h...
>
> > window server is down from over 12 hrs - 2 new
> > ----------------------------------------------
> > < add name="appConnection" connectionString="data source=208.43.72.251,8243;
> > Netw ork Library=DBMSSOCN;initial catalog=manager_vdnwext; User id=vdnext;
> > Password=123456" providerName=" System.Data.SqlClient"/> < remove name="
> > LocalMySqlServer" /> </ connectionStrings> Server Error in '/' Application.
> > ---
> > --------------------------- - Wed, Dec 24 2008 8:23 am
> > 2 messages , 2 authors
> >http://groups.google.com/group/DotNetDevelopment/t/fe34e36a64d01155?h...
>
> > ===========================================================================­===
>
> > You received this message because you are subscribed to the Google
> > Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web
> > Services,.NET Remoting" group.
>
> > To post to this group, send email to [email protected] or
> > visithttp://groups.google.com/group/DotNetDevelopment?hl=en
>
> > To unsubscribe from this group, send email to
> > [email protected]
>
> > To change the way you get mail from this group, visit:
> >http://groups.google.com/group/DotNetDevelopment/subscribe?hl=en
>
> > To report abuse, send email explaining the problem to [email protected]
>
> > ===========================================================================­===
> > Google Groups:http://groups.google.com/?hl=en
>
> --
> Esoimeme George,
> Ericsson Charging System Consultant,- Hide quoted text -
>
> - Show quoted text -

Reply via email to