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

Unable to store user data in user settings in vsto for outlook 2013

$
0
0

Hi there

I've developed a simple plugin for outlook 2013 which takes an entry from the text box and saves it in the user settings

Properties.Settings.Default.confId = cpIdtxt.Text.Trim();     

Properties.Settings.Default.Save();

and then I retrieve it after 

Properties.Settings.Default.confId

It works on my development environment but when I package it and deploy it on the client's machine usingadvanced installer it doesn't work persistently what could be the reason? 

Thanks



Find and replace for Strings over 255 charaters in Word

$
0
0

I'm trying todo a find and replace in Word 2003, replacing a found item with a string that is greater than 255 characters in length (believed to be the limitation due to the find and replace in word).  My plan was todo a find to highlight what i wanted to replace, then just inserting text over that highlighted area, unless there is a better solution. 

If this is the best solution how do I go about setting the range values required to insert over the already highlighted text?


Any help would be greatly appreciated :)

VSTO | Word | Range compare

$
0
0

Hi,

I'm trying to work out if two ranges in Word intersect. I'm just interested in whether they intersect or not, I don't need to know how they intersect. I originally thought this would be easy, all I need to do is compare the start and end values and in a simple text document his is sufficient. The problem I have is with text boxes. If I start with a new document and add "Hello, World" on the first line, then add a text box containing "Hello, World", then compare the range start / end values for both "Hello, World",s you end up with the same numbers.

Is it possible to differentiate the two ranges? How does the range in the text box know it's within a text box?

Many thanks for any pointers that can be provided.

Martin

VSTO OUTLOOK can't get ribbon bar to show on new message window

$
0
0

Hi,

I am currently using a custom ribbon bar in Outlook but seem to be having problems hiding and showing the ribbon items dynamically. In my code when a new Inspector is created i show the custom ribbon.

Code

 void Inspectors_NewInspector(Outlook.Inspector Inspector)
  {
          ThisRibbonCollection ribbonCollection1 = Globals.Ribbons[Globals.ThisAddIn.Application.ActiveInspector()];
          ribbonCollection1.Ribbon.groupCustomRibbon.Visible = true;

}

The issue is that this works fine the first time outlook starts and a new message window is opened.  However if you open the window again, it does not work.

I've set breakpoint on the event and Inspectors_NewInspector gets hit each time. It just will not work the next time i open the window. If i close Outlook then reopen it again it works again for the first time.

i can also see that the property is being set to True, however its not showing up in the new message window.

not sure what to try at this point.

Zip gets corrupt after attaching and sending via vsto in online mode (VSTO, Office 2016, Exchange 2016, C#)

$
0
0

Hi,

we have an vsto addin which, with a click on a button, saves the attachments, zip them and reattaches the zip to the mail. After this it sends the mail with MailItem.Send();

This used to work fine but we have a strange issue with one of our customers.

He uses Office 2016 on Terminal Server with online mode and has an Exchange 2016.

If he sends e.g. 3 times the same mail with the addin one of these mails has just an empty zip attached without any files in it.

We debugged the process and the zip is correctly attached in the mail (all files show up and you can open the files in the zip) before sending with MailItem.Send().

After sending the mail the zip has only 4kb and has no files in it (mail in sent items and also the received mail). If I download the zip to the desktop the size on disk is zero.


This only happens in online mode not in cached mode.

If you open the zip manually before sending, the zip does not get corrupted after sending.

This also happens if we do not use mailitem.send() but the customer sends manually after the zip is attached by the addin.

It seems that in online mode the exchange server is aware of the zip but fails to upload the zip to the mail and only sends an empty container. The strange thing is that it works sometimes and sometimes not.

In the code we release all outlook objects with marshal.releasecomobject.

At the moment I really don't know what this could be. For sure it has to do something with the customers infrastructure because with other customers the problem never occurred.

Does anyone have any idea what this could be, any similar experience or idea where to look (logs etc.)?

Thank you very much

Mark


Regards Mark





VSTO Outlook 2016 addin gets disappeared from the add-ins tab

$
0
0

My addin is developed in VS 2015, and I have created the installer with installshield.

I create a registry key in "HKLM\Software (64 bit)\Microsoft\Office\ClickToRun\Registry\Machine\Software\Wow6432node\Microsoft\Office\Outlook\Addins\my_vsto_addin\" with below keys:

Description, FriendlyName, LoadBehavior, Manifest.

I have also signed the addin with a code signing certificate issued by "DigiCert SHA2 Assured ID Code Signing CA".

The problem is, whenever office 2016 gets updated, the addin no longer appears in the Outlook Options\Add-ins tab. But, the binary files are still available in the installation folder. Until the office update, the addin works fine.

Any ideas how to prevent this?

The ad-ins tab also does not show the Publisher name of the addin though I have set this up in the publish\Options tab of the addin project. Note: I don't publish the addin from this tab. Instead I create the setup file using installshield. I looked at the vsto file, and it contains a different publisher name (looks like its my product name) in the <description> node.

Any help will be highly appreciated.



Webbrowser control inside custom taskpane not showing loaded webpage

$
0
0

Hi,

I have created Outlook Add-in which, used custom pane to log in user into Salesforce.

In custom taskpane,User control was added which has webbrowser control.

Now from last few days,the custom taks pane is loaded but no login webpage is shown.I have also tried with other URLs.

Was there any update which has happened recently,which may be causing the issue.

Here is the link to the addin video:https://www.facebook.com/Point5Nyble/videos/2080581445493387/

private void MailTangy_Load(object sender, RibbonUIEventArgs e)
        {
            myCredentials=myCredentials.deserializeCredentials();
            //check if credentials have not expired.
            if (HasLoginExpired().Result==true)
            {
                Globals.ThisAddIn.myCredentials = null;
                if (loginPane == null)
                {
                    loginPane = new LoginCustomPane();
                    taskPaneValue = Globals.ThisAddIn.CustomTaskPanes.Add(
                        loginPane, "Login | Salesforce");
                    taskPaneValue.DockPosition = MsoCTPDockPosition.msoCTPDockPositionFloating;
                    taskPaneValue.DockPositionRestrict = MsoCTPDockPositionRestrict.msoCTPDockPositionRestrictNoChange;
                    //Move Login Window to Center

                    //End
                    taskPaneValue.Height = 575;
                    taskPaneValue.Width = 540;
                    taskPaneValue.Visible = true;
                    taskPaneValue.VisibleChanged += TaskPaneValue_VisibleChanged;
                }
            }
UserControl which was added:
 public partial class LoginCustomPane : UserControl
    {
        Credentials myCredentials = new Credentials();
        string redirectURL = Properties.Settings.Default.RedirectURL;
        public LoginCustomPane()
        {
            InitializeComponent();
            string url = "https://login.salesforce.com/services/oauth2/authorize?response_type=code&client_id=" +"3MVG9d8..jksdakdaHadaDoPDosVQgzlKdbddzLx48u68paKUn8o_UK2ZcZBFu9aQ7_DFPz&redirect_uri=" + redirectURL;
            //string url = "http://www.google.com";
            webBrowserLogin.Navigate(url);           
            webBrowserLogin.TabIndex = 0;
            webBrowserLogin.TabStop = true;
            webBrowserLogin.NewWindow += new CancelEventHandler(wb_newWindow);
            webBrowserLogin.Visible = true;         
        }


Point5Nyble

How to map word/sentence position in OpenXML to a range in MS Word?

$
0
0
I'm developing the VSTO Add-In for MS Word and have faced the issue with performance. My Add-In goes through all paragraphs in the document, analyzes sentences and words and extract those which match some criteria, then I save it with the matched Range object so that I could easily navigate to it after that. The performance at this moment is very slow because the analyzer doesn't match a word or pair of words only, but also takes in account formatting (bold, italic etc.) and about 85% of CPU goes to external code which I believe goes to invoking COM components, serialization and deserialization. I believe I can re-implement the Add-In to use the OpenXML SDK, but I have not figured out if it's ever possible to match the position of word or sentence in OpenXML document to the position (Range) in the Word document so that once found I could navigate to it inside of MS Word. If it's possible could you please point me out to the right direction?

Invalid provider type specified error in code signing the vsto outlook application

$
0
0
I brought a code signing certificate from GoDaddy generated a .pfx file from it. But when I use this file to code sign the ClickOnce manifest of my outlook  add-in application I get this error in visual studio

An error occurred while signing: Invalid provider type specified. 


What could be the problem here? Thanks.




Run operation in UI thread from background thread

$
0
0

Hi

My Outlook initialization is asynchronous (using TPF with an StaTaskScheduler) - but when it is done, I'd like to execute certain operations that access the outlook object model - so GUI thread it is.

I know how to do it in WPF and Winforms, but what about a VSTO add-in? 

Regards

Stephan

Attachment field

$
0
0

Hello Access community,

I give a discription of my situation:

First Acces: In Access i have made 15 related databases in one group. One off the databases is called Situatie. (Situation). That database consist of 3 columns: Situatienummer, Winternormnummer, Weather300. It does'nt matter how they are called, but this is in Dutch. Situatienummer is a referencekey and Winternormnummer is the KEY field. And Weather300 is from the type Attachment. And consist of 3 sub fields: 1. FileData 2. FileName 3. FileType.

Second the language vb: (Visual basic in Visual Studio 2017 community NOT the visual basic for Office!):

In vb i have written a project with severals forms for diverent items. One of the items is to save a web page into the database Situatie. Ofcourse i have a connection with the server Microsoft.ACE.OLEDB.12.0. And i work with the ADODB command for the query. And i have the src out off the web page. And the src is a Windows.Drawing.Image file. The Attachment field is made by Microsoft aspecialy for saving images. And spreadsheets etc.

When i have insert the image file (src) into the parameters, with the help off the insert query inside the Adodb command, then i run the program. The compiler doesn't believe what he is seen. And told me: "I can't save the fundamentals to a field that consist of more fundamentals".  Microsoft never realised that you can't save a file to a field that contains more then one field!

My question is: Do you know how to save that file into that attachment field? And can you give me a little sample code for it?

I hope that i have explained my situation clearly. And that there is a possibility to save that file. I can't imagion myself that Microsoft has made someting that can't be used. By no body.

Best regards,

Willem.

CustomTaskPane VSTO addin does not show

$
0
0
CustomTaskPane VSTO addin does not show

VTSO | Microsoft Word | Ranges | Cut & Paste

$
0
0

Hi,

I'd like to write an MS Word VTSO add-in that conditionally 'hides' selected range of the document. The selected range could be a drag selection of text, images, lines, etc associated with a bookmark. On the action of a button I'd then like to hide the range and then, later, put it back. 

It does seem possible to cut the range to the clipboard, save it away as RTF, and then put it back but this does not always work. If you select a shape - a line for example - then you can't save it in RTF, you can only save it as "Art::GVML ClipFormat" but then you can't paste it back into a range - you just get notification of the paste failing and no inner exception to explain why!

These objects are also interesting in that in Word if you select a line, cut it and paste it back, then it does not go back where it was. It as thought the cut & paste does not preserve the anchor information.

Any suggestion on how to hide / restore ranges would be appreciated!

Martin

Interop.PowerPoint: copy one chart data source to another

$
0
0

Sorry for my English

Task

Help me finish method which move source chart shape to destination chart shape according to the following logical:

  • assign source chart type to destination chart.
  • assing source chart data to destination chart.
  • everything else properties must be keep as destination chart

Beginning

using PP = Microsoft.Office.Interop.PowerPoint;
using XL = Microsoft.Office.Interop.Excel;

namespace SoInteropPp
{
    internal static class ChartSamples
    {
        internal static void MoveChart(PP.Shape sourChart, PP.Shape destChart)
        {
            // Validate
            if (sourChart.HasChart == MsoTriState.msoFalse || destChart.HasChart == MsoTriState.msoFalse)
                throw new ArgumentException();

            // Process type.
            destChart.Chart.ChartType = sourChart.Chart.ChartType;

            // Move source chart data source to destination chart.
            var sourBook = sourChart.Chart.ChartData.Workbook as XL.Workbook;
            var destBook = destChart.Chart.ChartData.Workbook as XL.Workbook;

            //...?
        }
    }
}

My research

If I have understood correctly, need

  1. Define which worksheet in sourBook contains source chart data.
  2. Define which range of worksheet contains data source.
  3. Copy got range (step 2) to destination worksheet
  4. Assign copied range to destChart via destChart.SetSourceData().

Question

I cannot (do not know) implement steps described above via Interop.PowerPoint APIs. How archive these steps or there is may be another some way?

Problem: Building a Managed Automation Add-In That Provides User-Defined Functions (Failed)

$
0
0

Hi,

I’m trying to learn VSTO I’ve installed Visual Studio Community 2017 and Office 2010 and I’am following Carter Lipper book

I make the following step:

1) launch Visual Studio as administrator and create a new C# class library project.Name the project AutomationAddin. Replace Class1 with the following code:

using System;

using System.Runtime.InteropServices;

using Microsoft.Win32;

namespace AutomationAddIn

{

        [Guid("0EDD997D-9C02-4684-B73A-1370D3DD2555")]

       [ClassInterface(ClassInterfaceType.AutoDual)]

       [ComVisible(true)]

       publicclassMyFunctions

       {

           public MyFunctions()

           {

           }

           publicdouble MultiplyNTimes(double number1,

           double number2,double timesToMultiply)

           {

               double result = number1;

               for (double i = 0; i < timesToMultiply; i++)

               {

                   result = result * number2;

               }

               return result;

           }

           [ComRegisterFunctionAttribute]

           publicstaticvoid RegisterFunction(Type type)

           {

               Registry.ClassesRoot.CreateSubKey(GetSubKeyName(type, "Programmable"));

               RegistryKey key = Registry.ClassesRoot.OpenSubKey(GetSubKeyName(type, "InprocServer32"),true);

               key.SetValue("",System.Environment.SystemDirectory +@"\mscoree.dll",RegistryValueKind.String);

           }

           [ComUnregisterFunctionAttribute]

           publicstaticvoid UnregisterFunction(Type type)

           {

               Registry.ClassesRoot.DeleteSubKey(GetSubKeyName(type, "Programmable"),false);

           }

           privatestaticstring GetSubKeyName(Type type,string subKeyName)

           {

               System.Text.StringBuilder s = new System.Text.StringBuilder();

               s.Append(@"CLSID\{");

               s.Append(type.GUID.ToString().ToUpper());

               s.Append(@"}\");

               s.Append(subKeyName);

               return s.ToString();

           }

       }

}

2) I’ve got my own GUID string by choosing Tools > Generate GUID.

3) In properties designer for the project ( Build tab) I’ve checked the check box labeled Register for COM Interop,

4) I’ve clickéd Build ( Buld executed with success)

Then I go to my Addin in Excel:

1). Launch Excel, and click the Microsoft Office button in the top-left corner of the window.

2). Choose Excel Options.

3). Click the Add-Ins tab in the Excel Options dialog box.

4). Choose Excel Add-Ins from the combo box labeled Manage, and click the Go button.

5). Click the Automation button in the Add-Ins dialog box.

6). Look through the list of Automation Servers, ……and I don’t find in the the list AutomationAddin.MyFunctions Class… why?,

I’ve tried with many different code found on the .Net and nothing change

Someone can help me to understand?

(Sorry for my English)Thank you


VSTO | Word | Conditional Fields

$
0
0

Hi,

I've been looking at using fields to turn on / turn off ranges of a document based on the value of a custom document property. Adding a field such as:

{ if {docproperty xyzzy} = 0 "Zero" "One" }

will basically show the text "Zero" or "One" depending on the value of the custom property which is fine. If I then edit the field and insert an image within the text "One" then then image is conditionally displayed too.

Taking this one set further I'd like to be able to drag select a region and then add a condition field to the selected region so effectively I'd like to create, in code, something like:

{ if {docproperty xyzzy} = 0 "<selected range." "" }

A field can be added with code such as:

            Range r = Globals.ThisAddIn.Application.Selection.Range;

            object fieldIF = WdFieldType.wdFieldIf;

            object fieldDocProperty = WdFieldType.wdFieldDocProperty;

            Field f = r.Fields.Add(r, ref fieldIF, "{XYZZY} = 0 \"FRIDAY\" \"THURSDAY\"", true);

            Range ifExpressionRange = f.Code;

            var find1 = ifExpressionRange.Find.Execute("{XYZZY}");

            Object xyxxy = "XYZZY";
            r.Fields.Add(ifExpressionRange, ref fieldDocProperty, ref xyxxy, false);

But I don't want the text "FRIDAY" and "THURSDAY", I want to inject the selected range. Any suggestions would be greatly appreciated.

Martin 


License Terms of ‘Microsoft.Office.Interop.Excel.dll'

$
0
0

We have developed an application using Visual Studio 2013 ultimate for commercial use, in which we have a reference to ‘Microsoft.Office.Interop.Excel.dll'

Please confirm whether we can redistribute this dll to the client without any additional licenses

how to add a new option to context menu of hyperlink in an email for Outlook 2010?

$
0
0

I see Outlook 2010 provides a lot of things you can customize epsecially in terms of UI.

However, I did not find any document on how to customize context menu of hyperlinks in an email?

Specifically, I would like to add a menu item to open the link in a non-default brower. Now you select, copy, open (in the system wide default) the link in a browser.

Thanks,

Word 2016 / custom user pane / problem with multiple windows

$
0
0

Good evening,

I have got a problem with a VSTO add-in for word. The add-in has a custom user pane which is added if a document is opened or new created:

---

Public Class ThisAddIn
    Private myUserControl1 As System.Windows.Forms.UserControl
    Private WithEvents myCustomTaskPane As Microsoft.Office.Tools.CustomTaskPane

...

Private Sub Application_OpenDocument(ByVal Doc As Word.Document) Handles Application.DocumentOpen
        myUserControl1 = New MyUserControl
        myCustomTaskPane = CustomTaskPanes.Add(myUserControl1, "RIS Export")
    End Sub

Private Sub Applicaton_NewDocument(ByVal Doc As Word.Document) Handles Application.NewDocument
    myUserControl1 = New MyUserControl
    myCustomTaskPane = CustomTaskPanes.Add(myUserControl1, "RIS Export")
 End Sub

---

Then there is a custom button in the ribbon to make the user pane visible:

---

Imports System.Windows.Forms
<Runtime.InteropServices.ComVisible(True)>
Public Class RibbonConvert
    Implements Office.IRibbonExtensibility
    Private ribbon As Office.IRibbonUI

Public Sub OnActionTest3(ByVal control As Office.IRibbonControl)
        Dim pane = Globals.ThisAddIn.TaskPane

        With pane
            .DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionLeft
            .Width = myTaskPaneWidth
            .Visible = True
            Call Log(1, pane.Visible)
        End With
    End Sub

---

Most of the time the add-in works as expected: I can open documents or create new ones and in each of these documents I can toggle the user pane on (with the button ion the ribbon) and off (the X on the user pane) an on again. The user panes react independent so turn it on or off affects only the user pane in the active window.
However, in some cases the add-in reacts different. If I click the ribbon button to make the user pane visible, nothing happens in the active windows. Instead a user pane is shown in another (non-active) window. If I close that user pane, go back to the first document and click the button again, I get the same result. If I close the document where the user pane was shown and click the ribbon button in the first document, an error occurs that the user pane was disposed.
So, I have no idea what the problem is. Any help is very much appreciated.

Thank in advance,
Michael

Handling "Undo" button in Word 2016 ribbon XML and the callback events in C# addin project

$
0
0

Hi,

I need to control "Undo" button/gallery control  in Word 2016 desktop version like the RedoOrRepeat/Paste/Cut commands in Word ribbon.

The redo and other commands fire back to my C# code using "onAction" when ever user press Ctrl +Y or Ctrl +C etc. but it does not fire back for Ctrl +Z.

Tried with "<gallery idMso="Undo" onAction="ButtonClicked" />" but it does not fireback to my C# addin code.

Thanks in advance.

Viewing all 5157 articles
Browse latest View live


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