none
openFileDialog1 not working

    Question

  • in the code
    openFileDialog1 
    and anything with Excel has the I dont know wtf this is squiggly line under them 
    I added the com dlls windows excell 12 objects and widows forms object dll 
    any ideas why its not working


    the code below generate this error

    Error 1
    'converge.Form1' does not contain a definition for 'openFileDialog1' and no extension method 'openFileDialog1' 
    accepting a first argument of type 'converge.Form1' could be found (are you missing a using directive or an assembly reference?)
    C:\Users\robm\Documents\Visual Studio 2008\Projects\converge\converge\Form1.cs 22 18 converge






    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;

    namespace converge
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                this.openFileDialog1.FileName = "*.xls";
                if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    Excel.Workbook theWorkbook = ExcelObj.Workbooks.Open(openFileDialog1.FileName, 0, true, 5,"", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,0, true);
                    Excel.Sheets sheets = theWorkbook.Worksheets;
                    Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
                    for (int i = 1; i <= 10; i++)
                    {
                        Excel.Range range = worksheet.get_Range("A" + i.ToString(), "J" + i.ToString());
                        System.Array myvalues = (System.Array)range.Cells.Value;
                        string[] strArray = ConvertToStringArray(myvalues);
                    }
                }

            }


        }
    Monday, July 12, 2010 3:28 AM

Answers

  • Do you have an OpenFileDialog control on the form?
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by robMerritt Monday, July 12, 2010 4:04 AM
    Monday, July 12, 2010 4:00 AM
  • Do you have a reference set to Excel?

    Here is some info:

    First, set a reference to the desired version of the Microsoft Excel Object Library from the COM tab of the Add Reference dialog. The resulting reference appears as Microsoft.Office.Interop.Excel.

    Import the Microsoft.Office.Interop.Excel library in your code file. To keep the namespaces clear, consider using an alias.

    In C#:

    using Excel = Microsoft.Office.Interop.Excel;

    Hope this helps.


    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by robMerritt Thursday, July 15, 2010 7:20 PM
    Monday, July 12, 2010 4:49 AM

All replies

  • Do you have an OpenFileDialog control on the form?
    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by robMerritt Monday, July 12, 2010 4:04 AM
    Monday, July 12, 2010 4:00 AM
  • Yep that worked ... I am a dummy

     

    excel obj still giving me greif

    Monday, July 12, 2010 4:06 AM
  • Do you have a reference set to Excel?

    Here is some info:

    First, set a reference to the desired version of the Microsoft Excel Object Library from the COM tab of the Add Reference dialog. The resulting reference appears as Microsoft.Office.Interop.Excel.

    Import the Microsoft.Office.Interop.Excel library in your code file. To keep the namespaces clear, consider using an alias.

    In C#:

    using Excel = Microsoft.Office.Interop.Excel;

    Hope this helps.


    www.insteptech.com ; msmvps.com/blogs/deborahk
    We are volunteers and ask only that if we are able to help you, that you mark our reply as your answer. THANKS!
    • Marked as answer by robMerritt Thursday, July 15, 2010 7:20 PM
    Monday, July 12, 2010 4:49 AM
  • That too worked , as well I had added a reference to the excel 5.0 assembly as well as the excell 12 asembly that I actually wanted
    Thursday, July 15, 2010 7:21 PM