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

List of Word ribbon idMsos

$
0
0

Hi,

I'm working on a custom Word ribbon. Where can I find a list of the default idMsos like "Cut" or "Copy"?


Ribbon group item idMsos

$
0
0

Hi,

I would like to use the "Styles" ribbon group which normally is located on the "HOME" page. I know that the control name (idMso) is "GroupStyles". So this is how I add this ribbon group to my custom ribbon tab "My Tab":

<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
  <ribbon>
    <tabs>
      <tab id="TabCustomIns" label="My Tab">
        <group idMso="GroupStyles" />
      </tab>
    </tabs>
  </ribbon>
</customUI>

"GroupStyles" is a group of items. E.g. "Title", "Subtitle", "Heading 1", etc.

Now I would like to create a custom group which only contains "Heading 1" and "Heading 2".  Is this even possible? I can't find the corresponding idMsos for "Heading 1" and "Heading 2"...

Creating a trial version Installer for an Add In

$
0
0

I have gone through the guide to create an installer for an office application

https://msdn.microsoft.com/en-us/library/cc442767.aspx

However, I also need to make my office application a trial version for like 10 or 30 days and then ship it to my client. What would be the additional steps to do that?



ribbon.Invalidate Null Exception in C# VSTO add-in

$
0
0

I am creating an application level add-in for Word 2010 using C# VSTO. The add-in has a Custom Task Pane with its visibility controlled by a toggle button on a ribbon. The ribbon has been created with XML (not the Visual Studio Designer).

When I call ribbon.Invalidate from outside the add-in's ribbon class I cannot refresh my ribbon because it is null. I get a System.NullReferenceException that issues the message:

Object reference not set to an instance of the object

I suspect that the ribbon is null because the underlying XML is not loaded when it is called. I have tried many things including

https://social.msdn.microsoft.com/forums/vstudio/en-US/8c525cdd-ba86-4b34-b621-44eb7240b07a/invalidating-ribbon-from-outside-ribbon

which suggests defining a class-level Office.IRibbonUI in the ThisAddIn class, and setting the value of this in the Ribbon_Load callback. I still received the exception with this and all other attempts I made. Here's my code:

In the myRibbon class I have:

[ComVisible(true)]publicclass myRibbon :Office.IRibbonExtensibility{publicOffice.IRibbonUI ribbon;private bool isTaskPaneVisible;public bool IsTaskPaneVisible{
         get {return isTaskPaneVisible;}set{
             isTaskPaneVisible = value;// This is where the null exception is thrown
             ribbon.Invalidate();}}

and

publicvoidRibbon_Load(Office.IRibbonUI ribbonUI){this.ribbon = ribbonUI;}

In the ThisAddin class I have:

publicpartialclassThisAddIn{internal myRibbon myRibbon;

and

protectedoverrideMicrosoft.Office.Core.IRibbonExtensibilityCreateRibbonExtensibilityObject(){
    myRibbon =new myRibbon();return myRibbon;}

Any assistance in getting ribbon.Invalidate to function correctly when called from outside the ribbon class would be greatly appreciated.

how to check whether outlook is runnning background or foregrund?

$
0
0

hi,

i am developing a vsto add-in in excel, which includes a batch mail sending tool. in some place, i am trying to catch if outlook is running with the following code

        If Process.GetProcessesByName("OUTLOOK").Count() > 0 Then
            outApp = DirectCast(Marshal.GetActiveObject("Outlook.Application"), outlook.Application)
        Else
            outApp = New outlook.Application
        End If

it works fine while outlook is running in the foreground.

but when outlook is closed, in the first run, it still works but leaves the outlook running in background. and if i attempt to run the code second time, it doesnt work and give error at the above part of the code.

the whole code is below..

Sub batchmailgonder()
        Dim outApp As outlook.Application
        Dim outMail As outlook.MailItem

        Dim fm As New frmBatchMail
bastan:
        fm.ShowDialog()

        If fm.devammi = 0 Then Exit Sub 'when clicked Cancel in the form

        If Process.GetProcessesByName("OUTLOOK").Count() > 0 Then
            'here is the part where i get the error in the second part
            outApp = DirectCast(Marshal.GetActiveObject("Outlook.Application"), outlook.Application)
        Else
            outApp = New outlook.Application
        End If

        app.Range("a2").Select()
        Do While CStr(app.ActiveCell.Value) <> ""
            outMail = outApp.CreateItem(outlook.OlItemType.olMailItem)
            With outMail
                .HTMLBody = sRTF_To_HTML(fm.govde)
                .Subject = fm.konu
                .To = app.ActiveCell.Value
                If fm.devammi = 1 Then 'which means Go
                    .Send()
                Else 'which means preview
                    .Display()
                    outMail = Nothing
                    outApp = Nothing
                    fm.devammi = 0
                    GoTo bastan
                End If
            End With
            app.ActiveCell.Offset(1, 0).Select()
            outMail = Nothing
        Loop

        outApp = Nothing
        MsgBox("Mail gönderimi tamamlandı")

    End Sub


Dig your well before you are thirsty

Where can I get a certificate to sign my VSTO outlook addin?

$
0
0
I have a VSTO outlook add-in that I want to publish. When I install the vsto, Windows 10 says that the publisher is not trusted. To avoid this prompt, I know I might have to buy a certificate and sign my VSTO.

Visual Studio can generate Temporary certificate which is for development purpose, but not production, and is therefore not a trusted certificate.

My question is, where can I apply a trusted certificate? Is is OK from here?

https://www.comodo.com/e-commerce/code-signing/code-signing-certificate.php?key5sk0=2128&key5sk1=3495ec828039acf3e9b52f3c6a5284357b836811



My VSTO calls 3rd party SDK (by adding dll references), I am also wondering: is it enough to only sign my VSTO? or does the SDK also need to be signed?


Excel has stopped working... Excel 2016 32-Bit

$
0
0

Few Clients suffering Excel errors on my VSTO Add-in project, which closes all Excel process, and I can't even debug or find what causes it. I have very big big Sub. Tried on Excel 2007, 2010, 2013 works good. At the moment don't know how to solve this, any ideas?

From Windows Manager -> Event logs -> i Found Error description, but client Windows version is not English, it's Lithuanian: 

Sugadintos taikomosios programos pavadinimas: EXCEL.EXE, versija: 16.0.6001.1034, laiko žyma: 0x561f4475

Sugadinto modulio pavadinimas: ntdll.dll, versija: 10.0.10240.16430, laiko žyma: 0x55c599e1

Išimties kodas: 0xc0000374

Sugadintas poslinkis: 0x000d5c0c

Sugadinto proceso ID: 0x18d4

Sugadintos taikomosios programos paleidimo laikas: 0x01d1160897173810

Sugadintos taikomosios programos kelias: C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE

Sugadinto modulio kelias: C:\WINDOWS\SYSTEM32\ntdll.dll

Ataskaitos ID: db92d135-b60e-4bdb-ba87-e0247181b0ed

Sugadinto paketo visas pavadinimas: 


How to create a .msi in vs 2012?


How to find style count of particular style in VSTO word.

$
0
0

Hi All,

How to find style count of particular style in VSTO word. 

Thanks in Advance!!!!

Password text box in Excel Ribbon

$
0
0

Hi,

I've done a customization to the Excel Ribbon control to call external data source where user can needs to enter  user name & password. Password control shows everything that user is entering. Now there is a requirement from the client to hide the text like normal password control does. 

Checked other online sources, no solution found. 

1. How can i make this happen? Any solution for this?

2. I'm using VSTO 2010. Does VSTO 2013 support  this control?

Any suggestions/alternatives welcome.

Thanks in advance.

Regards.

Kelum


Programmatically Convert .docx to .pdf

$
0
0

Please excuse this question that isn't strictly a VSTO question; I figure there may be several people on this forum that can point me to the right direction or provide some helpful thoughts nonetheless.

 

Our requirement is to be able to create an installation on a workstation that does not have Office 2007 installed, that installs our application and sufficient additional libraries such that we can programmatically convert a Word 2007 .docx file to a .pdf file.   One programmatic solution, which Microsoft offers sample code for, relies on Word 2007 being installed on the workstation along with a Save As PDF add-on also being installed.  But we can't presume Office 2007 is already installed on the target machine.  3rd-party convert-to-pdf libraries exist, including those that can convert a Word 2007 document to pdf, but they appear to rely on Word 2007 being already installed on the workstation.

 

We are currently using Framework 3.0's System.IO.Packaging to program against the new Word 2007 format, but I'm unaware of it providing a convert-to-pdf facility within itself, such that deploying Framework 3.0 would be enough to meet our needs.  We're planning to deploy Framework 3.0, so if that's all that's needed, please let me know. 

 

Does Microsoft offer some sort of Office 2007 redistributable DLL(s) that we could include on an install, along with perhaps one of the 3rd-party print-to-PDF SDKs, that would give us what we need?

 

Thank you.

Accesss multiple textrange-selections (VB.NET)

$
0
0

In my PowerPoint 2013 I am able to select different ranges of characters in one or even in many shapes. e.g.

First shape has the text: "We will findthe solution!"

Second shape has the text: "And we will be fast."

The selected characters on the screen could be: "We find And we fast."

Now what do I have to do in my vb.net code to make all four textranges bold.

My code is as follows:

Dim oSelection As Selection = oActiveWindow.SelectionDim oTextRange As TextRange = oSelection.TextRangeIf oTextRange.Count >0Then
	oTextRange.Font.Bold = MsoTriState.msoTrueEndIf

But this code only changes the characters of the last selected textrange to bold. e.g. in this case only "fast." would be bold.

I have tried to experiement with Microsoft.Office.Core.textrange2 but here I get the error:

(Exception of HRESULT: 0x80004002 (E_NOINTERFACE))

Any help is very appreciated. Many thanks.

Unable to cast COM object of Office Interop Excel

$
0
0

I am trying to iterate through the worksheets of the current excel workbook, using Visual Studio to create a VB Excel VSTO.

Basically, when a user click a button added to the ribbon then the program should run through all of the worksheets and unlist any tables. I keep gettingInvalidCastException

An exception of type 'System.InvalidCastException' occurred in ConvertAllTablesToRange.dll but was not handled in user code

Additional information: Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Tools.Excel.Worksheet'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{297DC8D9-EABD-45A1-BDEF-68AB67E5C3C3}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I have tried a bunch of different things, but still seem unable to procure a solution:

    Private Sub Button1_Click(sender As Object, e As RibbonControlEventArgs) Handles Button1.Click
        Dim wks As Worksheet, objList As ListObject
        Dim nativeWorkbook As Excel.Workbook
        Dim xlapp As Excel.Application = Globals.ThisAddIn.Application

        nativeWorkbook = xlapp.ActiveWorkbook

        If nativeWorkbook IsNot Nothing Then
            'Dim vstoWorkbook As Workbook = Globals.Factory.GetVstoObject(nativeWorkbook)

            For Each wks In nativeWorkbook.Sheets
                For Each objList In wks.ListObjects
                    objList.Unlist()
                Next objList
            Next wks

        End If
    End Sub


Word Contextual Task Panes

$
0
0
Using VS 2013 and VB.Net can anyone tell me how to open programmatically, the "Format Picture" task pane?

Kind Regards, Rich ... http://greatcirclelearning.com

ContentControlOnExit is not fired if it is mapped to xml

$
0
0

I had a document with some contentcontrols. In my VSTO-Addin i use the events:
Private Sub ActiveDocument_ContentControlOnExit(ContentControl As ContentControl, ByRef Cancel As Boolean) Handles ActiveDocument.ContentControlOnExit
Private Sub ActiveDocument_ContentControlOnEnter(ContentControl As ContentControl) Handles ActiveDocument.ContentControlOnEnter

If i have no XML Mapping on the ContentControls all events works fine.
But if i have XML Mapped ContentControls and changed the content and leave the Control the Event "ContentControlOnExit" is never fired.

If i change from one Mapped ContentControl to an other ContentControl without changing text the Events are fired. But if i have changed the Text and go to an other ContentControlneither of the twois fired.

Is this a Bug or a feature? What can i do to get these Events?

If i use the Event "ContentControlBeforeStoreUpdate" i have no full access to the Document. An
Application.ScreenUpdating = False
give the error: "This object model command is not available while in the current event"

What can i do?




Best practices for making Office Add Ins

$
0
0

Hi,

I am relatively new to making VSTO add ins and just recently made my first proper application. During testing sometimes the Add In crashes due to an exception and then gets disabled. From a client's point of view that is obviously undesirable and it is not nice to ask the client to then go and into disabled add ins and mark it as always enable. 

One thing that comes up to my mind is to always have try catch in each method in my application so that nothing goes unhandled.

I am also worried about the resources that are created or consumed by the Add In. Do I need to specifically release those sources in This addin shutdown event handler or Office takes care of those details behind the scenes. 

The purpose of this question was mainly to ask from experts what are the best practices in making COM Add Ins, what are the things to take care and look for. I hear from people that COM Add Ins are no longer the preferred choice for developing Office applications as they are not reliable and are bound to cause problems. What are the current alternative to developing Office Solutions?

Name within Microsoft Office Customization Installer for VSTO-project

$
0
0

I'm creating an Add-In for Outlook 2010 with Visual Studio 2015.

How can I change the name, which is displayed in the "Microsoft Office Customization Installer"?

Publisher within Add-Ins in Outlook Options

$
0
0

I'm creating an Add-In for Outlook 2010 with Visual Studio 2015.

How can I add the publisher name, which is displayed in Outlook in File -> Options -> Add-Ins? I'm signing my .vsto-File with a certificate and in the "Microsoft Office Customization Installer" the publisher is correctly shown...

VSTO Runtime Installation

$
0
0

I noticed the below in the MSDN documentation concerning the VSTO runtime installation.

"How to: Install the Visual Studio Tools for Office Runtime - You do not need to install Microsoft Office applications on computers that you install the Visual Studio Tools for Office runtime on. For example, you can install the runtime on a server and use the ServerDocument object to access document files. If you do need Office applications on the computer,
install them before you install the runtime. If you install Office after installing the runtime, you must run VSTOR.exe again and repair the installation."

This seems like a hassle, since the end-user will install my app and I have no control over whether they install it before and/or after MS Office.  I just need it to "work" :-)

Has anyone figured out a smooth way to package the VSTO runtime with your app such that it "just works"?  Is there some way of detecting that VSTO needs to be re-run?

 

Activeworkbook keeps changing in Excel 2013

$
0
0

In my Excel
vsto in 2013, I am finding that the vsto code is not sure what the active
workbook is if the vsto code opens a new workbook. Everything works fine
in Excel 2010 and 2007 however.

It seems that
in Excel 2013 globals.thisaddin.application.activeworkbook is specific to the
class/module that the code is currently in.

For example:

I am in
Workbook1 and I select a button that starts my code:

In Sub1 I
call another subroutine, Sub2 which is in another class object 

In Sub2 I
open a new workbook: workbook2

At this point
the Watch shows that globals.thisaddin.application.activeworkbook.name is the
same as the workbook I have just opened: workbook2. This is correct

When sub2
finishes, control passes back to Sub1, now the globals.thisaddin.application.activeworkbook.name
is now back to displaying workbook1 - although I have done nothing to change
the activeworkbook

Because the
rest of the code in Sub1 should apply to the activeworkbook, in Excel 2013
it updates workbook1 whereas in Excel 2010 and 2007 it updates workbook2.

Currently my fix is to check I am in the workbook I think I am before I can do anything.

    Public Sub ActivateWorkbook(ByVal strName As String)
        For Each wkbk As Excel.Workbook In app.Workbooks
            If wkbk.Name.ToUpper = strName.ToUpper Then
                wkbk.Activate()
                Exit For
            End If
        Next
    End Sub

For example when
I use wks.select  I now have to first check whether the activeworkbook is
the parent object of wks.

Am I doing something wrong or will I have to rewrite my vsto for Excel 2013, ensuring the
activeworkbook is always set back to the one I thought it was?



Viewing all 5157 articles
Browse latest View live


Latest Images