Quantcast
Channel: Visual Studio Tools for Office (VSTO) forum
Viewing all 5157 articles
Browse latest View live

How can I copy data of a usercontrol when usercontrol is copied

$
0
0

I am currently writing a VSTO Excel "Application-Level" Add-In using C#.

I have written a quite complex UserControl, that has several properties, which can be changed at runtime.

Therefore I defined a UserControlData class which is private to my UserControl.

I managed to store all this data in the CustomXmlParts section of the workbook.

However what I can not find out is, how to pass this information to the duplicated control when using ctrl-c/x ctrl-v.

Is there a concept for this task?

Regards, Helmut


Custom Task Pane not visible

$
0
0

Hi Everyone,

I developed Excel Add-ins in Visual Studio 2013.  The problem that I am facing is "Not showing the Custom Task Pane  when ever open any saved excel file in office 2013".    The Custom Task pane is visible If I debug or run from Visual  Studio 2013.  Please help how to resolve this issue.

I used the Microsoft Visual Studio 2013 and Microsoft Office Professional Plus 2013.

Below is the code to understand.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;

namespace ExcelAddInTest
{
    public partial class ThisAddIn
    {
        private Microsoft.Office.Tools.CustomTaskPane myCustomTaskPane;
        private MyUserControl myUserControl = new MyUserControl();

        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
                myUserControl = new MyUserControl();
                myCustomTaskPane = CustomTaskPanes.Add(myUserControl, "My Custom Task Pane");
                myCustomTaskPane.Visible = true;
                myCustomTaskPane.Width = 500;
            }
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        #region VSTO generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InternalStartup()
        {
            this.Startup += new System.EventHandler(ThisAddIn_Startup);
            this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
        }

        #endregion
    }
}

Thanks,

Rama Rao P.V.

Enable formatting in locked content control

$
0
0

I have a requirement to restrict adding/removing content within specific content controls in a Document-level addin, but to allow formatting changes such as Bold and Italic.  I can achieve the first part by setting the control's LockContents property to True, but I haven't found a way to enable formatting on a locked control, other than by intercepting keystrokes for control-key commands.

I've tried setting a callback for the Bold command's getEnabled property in our custom Ribbon.xml, and returning True after locking a control programmatically; the callback fires, but the control remains disabled.

Another option would be to simulate the locking of a control, but only prevent actions that would change the content.  This seems like a more complicated approach, but it would serve the purpose.

Is there any way to achieve the desired behavior through either approach?


squincy

VSTO Ribbon Commands section + Load Behavior 9 problem

$
0
0

I am working on Adin for Microsoft Word.

I have defined command subscribing to copy, cut and paste commands in my ribbon.xml. In
load Behavior 3 everything works as expected.

Now I want to run my Adin in Load Behavior 9 mode to improve start up time of Word, but regular copy, cut and paste actions in Word will not work until my Adin will be initialized through the first ribbon button click or I remove commands section from ribbon.xml.

Image extraction with high quality

$
0
0

Hello Everyone,

I have created a word add-in using C#.Net. In application, we are extracting the images from the document, but we are getting image quality issues. Here is the code written:

System.Windows.Forms.Clipboard.Clear();
sourceElement.Range.Select();
wxApp.WdApplication.Selection.Copy();

if (System.Windows.Forms.Clipboard.GetDataObject() != null)
{
 var data = System.Windows.Forms.Clipboard.GetDataObject();

                if (data != null && data.GetDataPresent(System.Windows.Forms.DataFormats.Bitmap))
                {
                    var image = (System.Drawing.Image)data.GetData(System.Windows.Forms.DataFormats.Bitmap, true);
                    var currentBitmap = new System.Drawing.Bitmap(image);
                    currentBitmap.Save(str_ImageDirectoryPath + "\\" + APIUtility.ReplaceIllegalCharacters(str_imageTitle) + imageExtn);
                }
            }

Here, the images extracted from the document is of very poor quality. Kindly let us know, how can I improve the quality of the images. If anyone has any example/code block, please let me know.

Thanks,


Shahab Abbasi

"Program files" directory problem during Microsoft Office Customization Installer in non-English versions of Windows

$
0
0

We have a document-level customization solution for Word and are experiencing problems during deployment in an environment running on terminal services. The OS (Windows 2012) is English and Word (2013) is non-English (German). 

Installation is done into the "Program Files" folder correctly. But when trying to start a word document linked to the specific template. The "Microsoft Office Customization Installer" pops up with the error.

"There was an error during installation"

From: file:///C:/Programme/[CompanyName]/[Productname]/[Productname].vsto

Downloading file:///c:/Programme/[CompanyName]/[Productname]/[Productname].vsto did not succeed.

Exception: ....

System.Deployment.Application.DeploymentDonwloadException: Download file:///C:/Programme/[Companyname]/Productname]/[Productname].vsto did not suceed. ---> System.Net.WebException: Could not find a part of the path 'C:\Programme\[Companyname]\[Productname]\[Productname].vsto'. ---> System.Net.WebException: ...... ---> System.IO.DirectoyNotFoundException......

The problem seems to be that the installer is looking for C:\PROGRAMME instead of C:\PROGRAM FILES. C:\PROGAMME is the German localized name of PROGRAM FILES (http://en.wikipedia.org/wiki/Program_Files).

The installer installs the solution correctly deployed into c:\program files, but when the later a user tries to start it and the Microsoft Office Customization Installer is called, it tries to access the non-existing "c:\programme" folder. This doesn't exist, because Windows is English.

Is there any thing related to deploying solutions on a platform which has different languages (mixing/matching of OS language and Office language?)

Thank you for your help

Excel Addin ribbon disappearing on clicking hyperlink in excel sheet

$
0
0

We have an business requirement, to add a Column with a set of Hyperlinks to an Excel Sheet using  VSTO Add In. We are facing an issue where on clicking the hyperlink(which points to a corpnet site), the Excel Add In ribbon is getting disappeared.

For sharepoint sites, this ribbon is not disappearing

for other sites like google.com ribbon is getting disappeared

Could you please help us if any one have one have faced similar issue and fixed it

Error 0x800A01A8 thrown after Undo in PowerPoint

$
0
0

My code has to merge selected shapes into one by 1. finding the topmost shape 2. making combined string 3. putting string to the topmost shape 4. deleting other shapes. It works fine, but if user does UNDO (Ctrl+Z), and error 0x800A01A8 is thrown. Any ideas?

 
'_firstCoordinate stores .Top coordinates, _allCoordinates finds shapes through these coordinates
        Dim _firstCoordinate As New List(Of Single)
        Dim _allCoordinates As New Dictionary(Of Single, PPT.Shape)

'Omitted code for initiatization, sorting, etc
'====
'====

  'This works fine
        If _allCoordinates(_firstCoordinate(0)).HasTextFrame Then
            If _allCoordinates(_firstCoordinate(0)).TextFrame.HasText Then
                _combinedString = _allCoordinates(_firstCoordinate(0)).TextFrame.TextRange.Text + Environment.NewLine
            Else
                _combinedString = ""
            End If
        Else
            _exitMarker = True
        End If

'Make combined text string and delete shapes
        For i = 1 To _firstCoordinate.Count - 1 Step 1
            If _allCoordinates(_firstCoordinate(i)).HasTextFrame Then
                'This line throws error (.TextFrame.HasText)
                If _allCoordinates(_firstCoordinate(i)).TextFrame.HasText Then
                    _combinedString = _combinedString + _allCoordinates(_firstCoordinate(i)).TextFrame.TextRange.Text + Environment.NewLine

                    _allCoordinates(_firstCoordinate(i)).Delete()
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(_allCoordinates(_firstCoordinate(i))) : _allCoordinates(_firstCoordinate(i)) = Nothing

                End If
            End If
        Next



custom task pane visible is not working in Excel 2013

$
0
0

Hi 

I'm trying to enable the task pane (wpfcontrol) from C# code but it is not working in Excel 2013 but works fine in Excel 2007 and 2010

Code Snippet:

public partial class AddIn { private OfficeTools.CustomTaskPane _Pane; public OfficeTools.CustomTaskPane Pane { get { return _Pane; } set { this._Pane = value; } } private void AddIn_Startup(object sender, System.EventArgs e) { wpfControl = new WPFElementHostControl();

this.Pane=this.CustomTaskPanes.Add(wpfControl, "Dpane");

this.Pane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft; this.Pane.Width = 88; } //Now I'm trying to enable the the taskpane public void Rehydrate(Workbook Wb) { } Globals.AddIn.Pane.Visible = true;//(this line is not working in Excel 2013) }

Can anyone suggest a work around for above issue

Thanks In Advance


How to get the index of the word at current cursor position in the word?

$
0
0

Dear All

I am implementing a spell checker of my native language in Word. Whenever I run spell checker it start from the first word. How can I make it to start from the current cursor position? How can I get the index of the word at the current cursor position?

Thanks in advance.


Dharam Veer Sharma

Problem with display of mnemonics in dialog in word.

$
0
0

In my word 2010 addin I have a dialog for checking spellings. At the design time the mnemonics (underlined characters of controls) are visible however at run time the mnemonics are not visible (as in following image). They become visible only when ALT key is pressed .

Am I missing to set some property.

Please suggest what is needed?

Mnemonics are working but are not visible.

Thanks in advance.


Dharam Veer Sharma


Named ranges and COM Interop

$
0
0

I'm familiar with the no double dot rule to avoid the dreaded:

COM object that has been separated from its underlying RCW cannot be used

However I'm unsure how this holds up for VSTO objects.  As far as I can tell Iwould not need to release an object such as:

Globals.shtTime

As this is a native VSTO object (??)

However I would need to release the object:

Globals.shtTime.InnerObject

But is writing something like this ok?

Dim TargetRow As Integer = Globals.shtTime.rngMainTable.Row
I'm unsure whether that statement is creating a COM object that refers to my named range (rngMainTable)

Open Right Hand Pane and Set Focus

$
0
0

Hi All,

I have created a Ribbon for Microsoft Word using Dotnet 4(C#).

On click of my Ribbon item, the Right hand pane(RHP) is opened and the List of items are displayed in ItemControl with vertical Scroolbar which is present in RHP.
However the focus is not on the RHP meaning that you can’t scroll with the mouse wheel. The mouse wheel still scrolls the Word doc which feels odd.

I tried with the below code but its not working,

private static void AddTaskPaneToActiveWindow(UserControl uc, string Title = null)
        {
            //add task pane if needed
            if (ThisAddIn.Application.Windows.Count > 0)
            //if at least 1 doc window is open
            {
                var pane = ThisAddIn.CustomTaskPanes.Add(uc, Title ?? uc.GetType().Name, ThisAddIn.Application.ActiveDocument.ActiveWindow);
                pane.Width = ActiveWindow.Width / 2;
                pane.Visible = true;
                pane.Control.Focus();
            }
            else
            {
                var pane = ThisAddIn.CustomTaskPanes.Add(uc, Title ?? uc.GetType().Name);
                pane.Width = 400;
                pane.Visible = true;
                pane.Control.Focus();
            }
        }

Can someone please let me know how to set focus of RHP on displaying it.


Regards,
Chetan.


Chetan Rajakumar

Scroll bar for Custom Task Pane

$
0
0

Hi,

I have an add-in, developed using VSTO, that displays a custom task pane in Excel. This custom task pane holds a user control containing tree-view and other controls. I enabled AutoScroll for the user control and can see the traditional windows scroll bar when ever i re-size the CTP.

However, i want the scroll bar to be similar to the scroll bars that exist in Thesaurus CTP in Excel 2013,when the CTP is in floating position and re-sized to smallest size, as seen in the below image.

can any one provide pointers for this?

Also is there any way to restrict the minimum size of CustomTaskPane ?

Thanks

Guruteja

Unregistering Addin

$
0
0

I am running a VB program (Visual Studio 2010) on a computer with Windows 8.1 64-bit system The computer has 64 GB of RAM and an i7 processor.

After generating matrices of up to 25 columns x 900,000 rows, I write the matrix to a flat file, then invoke a macro in Excel 2013 (64-bit) to read in the matrix. This is the fastest way I have been able to devise. It worked fine until I installed Risk Solver Platform Addin from Frontline Systems (awesome software by the way).

I need to unregister the Risk Solver Platform Addin programmatically while the writing to Excel is done, then register it again after the file is closed. The following code was suggested:

To unregister

Shell("RegSvr32 ""C:\Program Files\Frontline Systems\Analytic Solver Platform\Bin\RSPAddin.xll"" /u /s")

To register

Shell("RegSvr32 "C:\Program Files\Frontline Systems\Analytic Solver Platform\Bin\RSPAddin.xll" /r /s")

The path for the file RSPAddin.xll is correct. At compile time, there are no diagnostics, but at run time, I get the following:

Any suggestions as to how this may be fixed?


Mike Allison


Grant Permissions to Folders and Assemblies (2003 System) through installer itself.

$
0
0

Dear All

Due to client requirement, I have developed an application level Add-in for Word 2003. After installation we need to grant permissions to folders and assemblies. On the end user computer it works if we manually run the following command

caspol -u -ag All_Code -url C:\<FolderName>\<FolderName>\* FullTrust -n "<Name>"

But leaving this for end user to run this command is not acceptable since all users can't do it for themselves.

Is there any way of getting this done through installer itself?

Please suggest alternative of doing it automatically through installer.

Thanks in advance.

Regards.



Dharam Veer Sharma

Customize ribbons

$
0
0

 

I am writing an Add-In for Word with ribbons. Now I want to add not only my buttons to the ribbon, I want to add already existing buttons like New Comment, Mail, etc.. It is possible to do this in Word, but I want to do it within Visual Studio to deliver a working solution. Does someone know if it is possible to do this?

 

Thx

VSTO Excel bug: clipboard null after PageSetup modification

$
0
0

Hi,

Found a bug in VSTO excel add-in.

Version:

Microsoft Visual Studio Premium 2012
Version 11.0.61030.00 Update 4
Microsoft .NET Framework
Version 4.5.50938
Installed Version: Premium

VSTO 10.0.50903

Problem:

When you open two or more workbooks, and try to copy and "paste special" from one to antoher, clipboard gets cleared automatically in scenario when you try to alter PageSetup object using application event.

Steps to reproduce:

1. Create an empty Excel add-in project.

2. Add event as in code below.

3. Run Excel

4. Ctrl+N spawn new excel

5. Try to copy and paste special to another excel window.

6. Clipboard is empty, copy failed...

Regards,

Bart

Code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using Excel = Microsoft.Office.Interop.Excel;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Tools.Excel;

namespace ExcelAddIn2
{
	 public partial class ThisAddIn
	 {
		  private void ThisAddIn_Startup(object sender, System.EventArgs e)
		  {
				this.Application.WorkbookActivate += Application_WorkbookActivate;
		  }

		  void Application_WorkbookActivate(Excel.Workbook Wb)
		  {
				foreach (Microsoft.Office.Interop.Excel.Worksheet item in Wb.Worksheets)
				{
					 item.PageSetup.LeftHeader = "&B Bold text &B";
				}
		  }

		  private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
		  {
		  }

		  #region VSTO generated code

		  /// <summary>
		  /// Required method for Designer support - do not modify
		  /// the contents of this method with the code editor.
		  /// </summary>
		  private void InternalStartup()
		  {
				this.Startup += new System.EventHandler(ThisAddIn_Startup);
				this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
		  }

		  #endregion
	 }
}



Excel Add-In with WorkbookOpen event causes error in Word

$
0
0

EDIT: New information

I have narrowed the problem to a specific code. Following code produces the error message (see below in the original part):

public partial class ThisAddIn
{
    private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        Globals.ThisAddIn.Application.WorkbookOpen += Application_WorkbookOpen;
    }

    void Application_WorkbookOpen(Excel.Workbook Wb)
    {
        int i = 0;
    }

    private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
    {
    }

    #region VSTO generated code

    /// <summary>
    /// Required method for Designer support - do not modify
    /// the contents of this method with the code editor.
    /// </summary>
    private void InternalStartup()
    {
        this.Startup += new System.EventHandler(ThisAddIn_Startup);
        this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
    }

    #endregion
}

It does not matter whether I unregister the WorkBookOpen event in the ThisAddIn_Shutdown method or not. Whenever this piece of code is present Word gives me the error.

It seems to be a bug in Excel. Can anyone test and confirm my assumption? Does anyone know a workaround?

ORIGINAL

I have a problem with my Excel add-in (VSTO) in a very specific situation. For some reason I can't debug the add-in when it is happening.

In Word it is possible to insert and edit OLE objects. In this specific situation a user wants to insert and edit an Excel sheet (INSERT -> Table -> Excel Spreadsheet).

Let's say that Excel is not running. In an ideal world the Excel process is started by Word when the user edits the spreadsheet. The Excel process is terminated when the Word document is closed. This works fine, if my Excel add-in is deactivated.

If the Excel add-in is activated the user cannot edit the spreadsheet in Word. An error with following message is shown within Word: "The program used to create this object is Excel. That program is either not installed on your computer or it is not responding. To edit this object, install Excel or ensure that any dialog boxes in Excel are closed". Also the Excel process which was started by Word is not terminated when closing the document or exiting Word. Excel started by the user does not give any error message. No dialog is opened. The add-in works fine. So there must be an error with the Excel add-in when Excel is started by Word.

I can reproduce the error with and without an attached debugger (Visual Studio). But for some reason there is no exception caught by Visual Studio while the error is happening.

Can anyone help me how to investigate on that error?

Yavuz


Issue installing Data Analysis Plus in OS 8.1 with MS Office Professional 2013

$
0
0

Hi. I am trying to install Data Analysis Plus and it won't install. An error occurs stating that:

The value of the property 'type' cannpt be parsed. The error is: Could not load file or assembly 'Microsoft.Office.BusinessApplications.Fba, Version=14.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified. (c:\Program Files (x86)\Common Files\Microsoft Shared\VSTO\10.0\VSTOInstaller.exe.Config line 10)

I have never had any other OS or MS Office version installed on this computer. I am running OS 8.1 and MS Office Professional 2013. I have tried to use the alternative version of installation by placing files in the appropriate folders, but to no avail. Please help! Thank you!

Viewing all 5157 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>