none
Microsoft.vbe.interop version 14.0.0.0 must be in stalled to GAC

    Question

  • Good day every one,

    I have created windows forms application on Visual Studio 2008 (win XP) and installed in our company.

    But a few days ago, i got windows 7 installed on my computer and office 2010.

     

    Now i created a new version of "ClickOnce" application and published on a server. When users are trying to update the programm they got a message:

    "Microsoft.vbe.interop version 14.0.0.0 must be in stalled to GAC. Please contact your system administrator."

    We have about 100 computer in the office and i don't want to install this update to all of them. Is it possible to do somethnig and do not get this message every time they want to update application?

     

    Thank you.

    Monday, April 25, 2011 8:05 AM

Answers

  • As you aren't using the VSTO technology, the VSTO forum isn't the correct place to ask this question.

    I'm therefore going to move the question to the General Office Development forum


    Cindy Meister, VSTO/Word MVP

    Dear Cindy,

    thank you for reply. Meanwhile I found a solution.

    I'ts quite simple - to use "late bindings". Maybe this is an incorrect translation, sorry for that.


    Monday, April 25, 2011 1:57 PM

All replies

  • As you aren't using the VSTO technology, the VSTO forum isn't the correct place to ask this question.

    I'm therefore going to move the question to the General Office Development forum


    Cindy Meister, VSTO/Word MVP
    Monday, April 25, 2011 12:14 PM
  • As you aren't using the VSTO technology, the VSTO forum isn't the correct place to ask this question.

    I'm therefore going to move the question to the General Office Development forum


    Cindy Meister, VSTO/Word MVP

    Dear Cindy,

    thank you for reply. Meanwhile I found a solution.

    I'ts quite simple - to use "late bindings". Maybe this is an incorrect translation, sorry for that.


    Monday, April 25, 2011 1:57 PM
  • Class itself:
      public class My_Excel : IDisposable
      {
        public const string UID = "Excel.Application";
        object oExcel = null;
        object WorkBooks, WorkBook, WorkSheets, WorkSheet, Range, Interior;
    
    
        /// <summary>
        /// Constructor
        /// </summary>
        public My_Excel()
        {
          oExcel = Activator.CreateInstance(Type.GetTypeFromProgID(UID));
    
          // make it visible
          oExcel.GetType().InvokeMember("Visible", BindingFlags.SetProperty,
            null, oExcel, new object[] { true });
        }
    
    
        /// <summary>
        /// Visible / no
        /// </summary>
        public bool Visible
        {
          set
          {
            oExcel.GetType().InvokeMember("Visible", BindingFlags.SetProperty,
              null, oExcel, new object[] { value });
          }
          get
          {
            return Convert.ToBoolean(oExcel.GetType().InvokeMember("Visible", BindingFlags.GetProperty,
              null, oExcel, null));
          }
        }
    
    
        /// <summary>
        /// Scroll bars
        /// </summary>
        public bool DisplayScrollBarsVisible
        {
          set
          {
            oExcel.GetType().InvokeMember("DisplayScrollBars", BindingFlags.SetProperty,
              null, oExcel, new object[] { value });
          }
          get
          {
            return Convert.ToBoolean(oExcel.GetType().InvokeMember("DisplayScrollBars", BindingFlags.GetProperty,
              null, oExcel, null));
          }
        }
    
    
        /// <summary>
        /// Status bar
        /// </summary>
        public bool DisplayStatusBarVisible
        {
          set
          {
            oExcel.GetType().InvokeMember("DisplayStatusBar", BindingFlags.SetProperty,
              null, oExcel, new object[] { value });
          }
          get
          {
            return Convert.ToBoolean(oExcel.GetType().InvokeMember("DisplayStatusBar", BindingFlags.GetProperty,
              null, oExcel, null));
          }
        }
    
    
        /// <summary>
        /// Window title
        /// </summary>
        public string Caption
        {
          set
          {
            oExcel.GetType().InvokeMember("Caption", BindingFlags.SetProperty,
              null, oExcel, new object[] { value });
          }
          get
          {
            return Convert.ToString(oExcel.GetType().InvokeMember("Caption", BindingFlags.GetProperty,
              null, oExcel, null));
          }
        }
    
    
        /// <summary>
        /// Enumerator (all possible states of vindow)
        /// </summary>
        public enum XlWindowState
        {
          xlMaximized = -4137,
          xlMinimized = -4140,
          xlNormal = -4143
        }
    
    
        /// <summary>
        /// /Window state
        /// </summary>
        public XlWindowState WindowState
        {
          set
          {
            oExcel.GetType().InvokeMember("WindowState", BindingFlags.SetProperty,
              null, oExcel, new object[] { value });
          }
        }
    
    
        /// <summary>
        /// Open document
        /// </summary>
        /// <param name="name"></param>
        public void OpenDocument(string name)
        {
          WorkBooks = oExcel.GetType().InvokeMember("Workbooks", BindingFlags.GetProperty, null, oExcel, null);
          WorkBook = WorkBooks.GetType().InvokeMember("Open", BindingFlags.InvokeMethod, null, WorkBooks, new object[] { name, true });
          WorkSheets = WorkBook.GetType().InvokeMember("Worksheets", BindingFlags.GetProperty, null, WorkBook, null);
          WorkSheet = WorkSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, WorkSheets, new object[] { 1 });
          // Range = WorkSheet.GetType().InvokeMember("Range",BindingFlags.GetProperty,null,WorkSheet,new object[1] { "A1" });
        }
    
    
        /// <summary>
        /// Create new document
        /// </summary>
        public void CreateNewDocument()
        {
          WorkBooks = oExcel.GetType().InvokeMember("Workbooks", BindingFlags.GetProperty, null, oExcel, null);
          WorkBook = WorkBooks.GetType().InvokeMember("Add", BindingFlags.InvokeMethod, null, WorkBooks, null);
          WorkSheets = WorkBook.GetType().InvokeMember("Worksheets", BindingFlags.GetProperty, null, WorkBook, null);
          WorkSheet = WorkSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, WorkSheets, new object[] { 1 });
          Range = WorkSheet.GetType().InvokeMember("Range", BindingFlags.GetProperty, null, WorkSheet, new object[1] { "A1" });
        }
    
    
        /// <summary>
        /// Close document
        /// </summary>
        public void CloseDocument()
        {
          oExcel.GetType().InvokeMember("DisplayAlerts", BindingFlags.SetProperty, null, oExcel, new object[] { false });
          WorkBook.GetType().InvokeMember("Close", BindingFlags.InvokeMethod, null, WorkBook, new object[] { true });
          oExcel.GetType().InvokeMember("DisplayAlerts", BindingFlags.SetProperty, null, oExcel, new object[] { true });
        }
    
    
        /// <summary>
        /// Save document
        /// </summary>
        /// <param name="name"></param>
        public void SaveDocument(string name)
        {
          if (File.Exists(name))
            WorkBook.GetType().InvokeMember("Save", BindingFlags.InvokeMethod, null,
              WorkBook, null);
          else
            WorkBook.GetType().InvokeMember("SaveAs", BindingFlags.InvokeMethod, null,
              WorkBook, new object[] { name });
        }
    
    
        /// <summary>
        /// Cell backgroundcolor
        /// </summary>
        /// <param name="range"></param>
        /// <param name="color"></param>
        public void SetColor(string range, int color)
        {
          //Range.Interior.ColorIndex
          Range = WorkSheet.GetType().InvokeMember("Range", BindingFlags.GetProperty,
            null, WorkSheet, new object[] { range });
    
          Interior = Range.GetType().InvokeMember("Interior", BindingFlags.GetProperty,
            null, Range, null);
    
          Range.GetType().InvokeMember("ColorIndex", BindingFlags.SetProperty, null,
            Interior, new object[] { color });
        }
    
    
        /// <summary>
        /// Page orientation (enumerator)
        /// </summary>
        public enum XlPageOrientation
        {
          xlPortrait = 1, //Книжный
          xlLandscape = 2 // Альбомный
        }
    
    
        /// <summary>
        /// Setting page orientation
        /// </summary>
        /// <param name="Orientation"></param>
        public void SetOrientation(XlPageOrientation Orientation)
        {
          //Range.Interior.ColorIndex
          object PageSetup = WorkSheet.GetType().InvokeMember("PageSetup", BindingFlags.GetProperty,
            null, WorkSheet, null);
    
          PageSetup.GetType().InvokeMember("Orientation", BindingFlags.SetProperty,
            null, PageSetup, new object[] { 2 });
        }
    
    
        /// <summary>
        /// Page margins
        /// </summary>
        /// <param name="Left"></param>
        /// <param name="Right"></param>
        /// <param name="Top"></param>
        /// <param name="Bottom"></param>
        public void SetMargin(double Left, double Right, double Top, double Bottom)
        {
          //Range.PageSetup.LeftMargin - ЛЕВОЕ
          //Range.PageSetup.RightMargin - ПРАВОЕ 
          //Range.PageSetup.TopMargin - ВЕРХНЕЕ
          //Range.PageSetup.BottomMargin - НИЖНЕЕ
          object PageSetup = WorkSheet.GetType().InvokeMember("PageSetup", BindingFlags.GetProperty,
            null, WorkSheet, null);
    
          PageSetup.GetType().InvokeMember("LeftMargin", BindingFlags.SetProperty,
            null, PageSetup, new object[] { Left });
          PageSetup.GetType().InvokeMember("RightMargin", BindingFlags.SetProperty,
            null, PageSetup, new object[] { Right });
          PageSetup.GetType().InvokeMember("TopMargin", BindingFlags.SetProperty,
            null, PageSetup, new object[] { Top });
          PageSetup.GetType().InvokeMember("BottomMargin", BindingFlags.SetProperty,
            null, PageSetup, new object[] { Bottom });
        }
    
    
        /// <summary>
        /// Enumerator - page size
        /// </summary>
        public enum xlPaperSize
        {
          xlPaperA4 = 9,
          xlPaperA4Small = 10,
          xlPaperA5 = 11,
          xlPaperLetter = 1,
          xlPaperLetterSmall = 2,
          xlPaper10x14 = 16,
          xlPaper11x17 = 17,
          xlPaperA3 = 9,
          xlPaperB4 = 12,
          xlPaperB5 = 13,
          xlPaperExecutive = 7,
          xlPaperFolio = 14,
          xlPaperLedger = 4,
          xlPaperLegal = 5,
          xlPaperNote = 18,
          xlPaperQuarto = 15,
          xlPaperStatement = 6,
          xlPaperTabloid = 3
        }
    
    
        /// <summary>
        /// Setting page size
        /// </summary>
        /// <param name="Size"></param>
        public void SetPaperSize(xlPaperSize Size)
        {
          //Range.PageSetup.PaperSize - РАЗМЕР ЛИСТА
          object PageSetup = WorkSheet.GetType().InvokeMember("PageSetup", BindingFlags.GetProperty,
            null, WorkSheet, null);
    
          PageSetup.GetType().InvokeMember("PaperSize", BindingFlags.SetProperty,
            null, PageSetup, new object[] { Size });
        }
    
    
        /// <summary>
        /// Printing scale
        /// </summary>
        /// <param name="Percent"></param>
        public void SetZoom(int Percent)
        {
          //Range.PageSetup.Zoom - МАСШТАБ ПЕЧАТИ
          object PageSetup = WorkSheet.GetType().InvokeMember("PageSetup", BindingFlags.GetProperty,
            null, WorkSheet, null);
    
          PageSetup.GetType().InvokeMember("Zoom", BindingFlags.SetProperty,
            null, PageSetup, new object[] { Percent });
        }
    
    
        /// <summary>
        /// Rename current page
        /// </summary>
        /// <param name="n"></param>
        /// <param name="Name"></param>
        public void ReNamePage(int n, string Name)
        {
          //Range.Interior.ColorIndex
          object Page = WorkSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, WorkSheets, new object[] { n });
    
          Page.GetType().InvokeMember("Name", BindingFlags.SetProperty,
            null, Page, new object[] { Name });
        }
    
    
        /// <summary>
        /// Add new row
        /// </summary>
        /// <param name="Name">page name</param>
        public void AddNewPage(string Name)
        {
          WorkSheet = WorkSheets.GetType().InvokeMember("Add", BindingFlags.GetProperty, null, WorkSheets, null);
    
          object Page = WorkSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null, WorkSheets, new object[] { 1 });
          Page.GetType().InvokeMember("Name", BindingFlags.SetProperty, null, Page, new object[] { Name });
        }
    
    
        /// <summary>
        /// Activate worksheet by it's name
        /// </summary>
        /// <param name="_WorkSheetName"></param>
        public void ActivateWorksheetByName(string _WorkSheetName)
        {
          WorkSheet = WorkSheets.GetType().InvokeMember("Item", BindingFlags.GetProperty, null,
            WorkSheets, new object[] { _WorkSheetName });
          WorkSheet.GetType().InvokeMember("Activate", BindingFlags.InvokeMethod, null, WorkSheet, null);
        }
    
    
        /// <summary>
        /// Activate worksheet by it's number
        /// </summary>
        /// <param name="_WorkSheetName"></param>
        public void ActivateWorksheetByNumber(int _WorkSheetNumber)
        {
          WorkSheet = WorkSheets.GetType().InvokeMember("Item",
            BindingFlags.GetProperty, null, WorkSheets, new object[] { _WorkSheetNumber });
    
          WorkSheet.GetType().InvokeMember("Activate", BindingFlags.InvokeMethod, null, WorkSheet, null);
    
        }
    
    
        /// <summary>
        /// Quantity of worksheets in current workbook
        /// </summary>
        /// <returns></returns>
        public int GetWorksheetsCount()
        {
          string i =
            WorkBook.GetType().InvokeMember("Count", BindingFlags.GetProperty, null, WorkSheets, null).ToString();
    
          return Convert.ToInt32(i);
        }
    
    
        /// <summary>
        /// Apply font to range (by range)
        /// </summary>
        /// <param name="range"></param>
        /// <param name="font"></param>
        public void SetFont_ByRange(string range, Font font)
        {
          //Range.Font.Name
          Range = WorkSheet.GetType().InvokeMember("Range", BindingFlags.GetProperty,
            null, WorkSheet, new object[] { range });
    
          object Font = Range.GetType().InvokeMember("Font", BindingFlags.GetProperty,
            null, Range, null);
    
          Range.GetType().InvokeMember("Name", BindingFlags.SetProperty, null,
            Font, new object[] { font.Name });
    
          Range.GetType().InvokeMember("Size", BindingFlags.SetProperty, null,
            Font, new object[] { font.Size });
        }
    
       
    
      }
    
    the class itself if much bigger, but i can't insert it into this message. Everyone who need it, please send me an e-mail and i will reply full text.

     

    • Proposed as answer by Son Phuoc Wednesday, September 18, 2013 3:25 AM
    • Unproposed as answer by Son Phuoc Wednesday, September 18, 2013 3:25 AM
    Monday, April 25, 2011 1:59 PM
  • Hi Gennadiy

    "Late binding" is a correct English language term for what you've done, yes :-)

    Apparently, what has happened is that your project referenced the PIAs to an earlier version of Office. I'd have expected Office 2010 PIAs to automatically "re-route" references to earlier versions, but perhaps it doesn't work correctly with the VBE type library. It's not a library used often in the Office interop as it's the interface for creating/modifying VBA code in an Office file.

    Using late binding is an acceptable way to avoid version-dependency. Glad you've got things working!


    Cindy Meister, VSTO/Word MVP
    Tuesday, April 26, 2011 5:13 PM
  • Dear Cindy,

    I have the same problem as mentioned below. but couldn't get it done. can you please explain this late binding solution for me?

    Thanks.


    -Madura Shantha- Code as if the next guy to maintain your code is a homicidal maniac who knows where you live.

    Monday, October 08, 2012 4:15 AM