Hi All,
Well where I work they are having a problem and I had a solution. Well I was reading on this http://www.c-sharpcorner.com/UploadFile/mgold/HowtoOepnandReadanExcelSpreadsheetinaListViewin.NET11282005034134AM/HowtoOepnandReadanExcelSpreadsheetinaListViewin.NET.aspx?ArticleID=45ca62cf-fb3e-4f0b-b9a4-031b641aae3c

Well what it does is pull a named range, sticks the data in an array, my software does it's thing, then puts the changed data back into excel. I used the Office PIA and installed them and everything.

Several long nights, and much snaking I was done. I tested it and fixed some changes and it works beautiflully. I was so proud!!

Well I created a little setup packaged and started trying to install it on other machines. Well it installs prefectly but when I try to run the app a message box comes up and says in the title "Missing Reference", the message says "Please Reinstall Software'.

What?!? How can this be???? Well I did everything I know. Reinstalled it again and again, made sure the Office PIA were "registered" and installed. Made sure the .net framework was installed. Tried the install on several computers. Even installed VS.Net 2005 on another computer and when I open up the solution won't even build sucessfully.

So what it all boils down to is the app can only build and run on the original deveolper machines.

Here is the code, but the loops that I worked really hard on I deleted.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
//great for using missing.value;
using System.Reflection;
using Microsoft.Office.Core;
using System.Threading;
using System.IO;



namespace DeannaProj2
{
    public partial class Form1 : Form
    { 
        
        //declaring and object Called AppExcel
        private Excel.Application AppExcel = null;
       
        
        ArrayManipulator AM = new ArrayManipulator();

        string strSource = null;
        string strRowCount = null;
        public string [,] arrySingle = null;
               
      
        
        public Form1()
        {
            InitializeComponent();
        }


        //to take care of opening and picking the excel file
        private void btnExcel_Click(object sender, EventArgs e)
        {

            exceldata.ShowDialog();
            strSource = exceldata.FileName;
            lblSource.Text = strSource;

           
        }

        private void btnRow_Click(object sender, EventArgs e)
        {

            //to check to see if user has selected an excel file
            if (strSource == "")
            {
                MessageBox.Show("Please Pick An Excel File", "Error");
            }                                                         

            strRowCount = txtbxRowCount.Text;
            btnStart.Enabled = true;
            btnLabels.Enabled = true;
         
        }
        
  
        private void btnStart_Click(object sender, EventArgs e)
        {
            

            //to check to see if user has selected an excel file
            if ((strSource == "") || (strSource == null))
            {
                MessageBox.Show("Please Pick An Excel File", "Error");
            }

            //then creating and starting the application

            InitializeComponent();
            AppExcel = new Excel.Application();
            
            if (AppExcel == null)
            {
                MessageBox.Show("Could not start Excel");
                exceldata.ShowDialog();
            }


           //now declaring to start a new workbook                     readonly
            Excel.Workbook WB1 = AppExcel.Workbooks.Open(strSource, 0, true, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
                0, true, 0, 0);
            
                      

            //to get the compile a list of worksheets
            Excel.Sheets WBsheets = WB1.Worksheets;

            //get the first and only worksheet                    the  1 if for the first sheet in the workbook
            Excel.Worksheet sheet = (Excel.Worksheet)WBsheets.get_Item(1);

            //prep the row count by subtracting one cause of 0 based counting
            int intRowCount = System.Convert.ToInt32(strRowCount);
           
            strRowCount = System.Convert.ToString(intRowCount);

            //here to prep the rows by adding a Colum 5 ("E")
            strRowCount = "E" + strRowCount;

        
            //here you define your range        
            Excel.Range range = sheet.get_Range("A1", strRowCount);
            //here you pull the data out
            System.Array arryReturn = (System.Array)range.Cells.Value2;
          
        


            //good old cleanup
            arryReturn = null;
            arrySource = null;

             //end of dangerous code
             #endregion
       

             //to show excel
           // AppExcel.Visible = true;


          //going to kill excel so it removes the deadlock on the file
            KillExcel();
            

        }

        private void btnKillExcel_Click(object sender, EventArgs e)
        {
               //will call KillExcel procedure
            KillExcel();
        }

        private void btnLabels_Click(object sender, EventArgs e)
        {   //will build the schema for the array
            AM.arryTemp = new string[arrySingle.Length / 5, 5];
            //this will then copy the contents of the array ____MAKE NOTE_____
            Array.Copy(arrySingle, AM.arryTemp, arrySingle.Length);
            //Will start the multiplying process
            AM.Multiplexer();
            //Start the Write To Excel Process
            WriteToExcel();
         
        }

        public void WriteToExcel()
        {
            //then creating and starting the application

            InitializeComponent();
            AppExcel = new Excel.Application();

            if (AppExcel == null)
            {
                MessageBox.Show("Could not start Excel");
                exceldata.ShowDialog();
            }


            //now declaring to start a new workbook
            Excel.Workbook WB1 = AppExcel.Workbooks.Open(strSource, 0, false, 5, "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
                0, true, 0, 0);

            //to get the compile a list of worksheets
            Excel.Sheets WBsheets = WB1.Worksheets;

            //get the first and only worksheet                    the  2 if for the first sheet in the workbook
            Excel.Worksheet sheet = (Excel.Worksheet)WBsheets.get_Item(2);

            //will take the length of arryFinal and divide by five cause multi deimension array
            int intLenght = AM.arryFinal.Length / 5;


          

               //now that the array has then been fed and written to excel, the WorkBook must be saved to the hard drive
            sheet.SaveAs(strSource, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
                                    Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            try
            {

                //messagebox to show the process is done
                MessageBox.Show("The Multiplexing is complete.", "Completed");
            }
            catch
            {
                MessageBox.Show("Operation Cancled By User (Did Not Save Over)", "Error");
            }
        }

        public void KillExcel()
        {

            //this will fish out all the process that have excel
            //the secret is "process name w/o .exe"
            Process[] process = Process.GetProcessesByName("Excel");
            for (int i = 0; i < process.GetLength(0); i++)
            {
                //kills excel process
                process[i].Kill();


            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {

            #region Licensing
            //pulls the hostname (LBMISTECH1) all caps too
            string strHostName = System.Environment.MachineName;
            // add the "\r\n" so it will match the line we will pull out of the text file
            strHostName = strHostName + "\r\n";
            //will assign where the file needs to go
            string strPath = @"c:\windows\system32\work.mul";

            //see if file work.mul exists in sytem32 folder
            if (File.Exists(strPath))
            {
                MessageBox.Show("Welcome To Multiplexer.", " Written By Lee Hicks");
            }
            else
            {
                //this will execute if file is not present
                MessageBox.Show("Please reinstall application", "Missing reference");
                //will close the form
                this.Close();
                
            }

            //this will try to open the text file to see if anything exists
            try
            {
                //create a streamreader to read the text file
                StreamReader srWorkMul = File.OpenText(strPath);
                //dumb the contents from file to the string
                string strContents = srWorkMul.ReadToEnd();
                // test to see if contents of text file match the hostname
                if (strContents == strHostName)
                {
                    //do nothing
                }
                else
                {
                    MessageBox.Show("Please reinstall application", "Missing reference");
                   //once again kill sthe app
                    this.Close();
                }

            }
            catch 
            {
                MessageBox.Show("Please reinstall application", "Missing reference");
                //if the applications can't find the file to open will close it again
                this.Close();

            }
            #endregion


        }

       

       

        



    }// end class
}// end namespace

Also I did add my own little version of licensing so the company I work for dosen't take my program and sell it without me knowing it. If anyone can help me with the Office Primary Interop Assemblies I would be thankful. I need this asap and is currently rewriting my app using OLE DB and a SQL server. But I would like to atleast get this first version working so people and actually see that it works and my second version is comming along slowly.

Help plz!!!!
Lee

i didnt really read your code so im not sure what your doing with the data. but anyways im sure all you need is ms office installed on the machine for it to work.

if all you are doing is reading and writing to a excel file you could try using oledb with jet 4.0 and the excel driver in the conn string. then that will let you read the excel file like a database.

I'd have to agree with plazmo on this one.

You will probably have to have Office installed on all of the machines that you're planning on depolying to. I think that the Excel stuff you're doing relies upon COM, which in itself relies upon the regeistered presense of Excel/Office in order to do all of its work.

I hate to say your work was in vain, but if you had used oleDb with Jet4.0, as plazmo described, the only thing your clients would need is the correct version of .NET CLR installed on their machines.

Well I already checked that, all the computers where I work have Office XP. The users would hunt me if I didn't cause they all like Excel.

Well I will just have to accept that my work is in vain. Well thanks for all the feed back and I am working oledb. Just real slow cause I have never used it before till now.

Also just something to chew on. For Microsoft being big into programming and make VS you would think since they pride their product Office that they would make it much much easier to write apps, especially for their developing software. Ohhh well

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.