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

How to check Excel bit version 32 or 64 bit?

$
0
0

Hello,

How can we check what Excel bit version client is running?

I know I can do this in Excel via VBA, but I have no idea how to check in C# Excel-AddIn then user trying to launch it.

I can create function in VBA and from C# call it and get return, but maybe there is straight method?

Thanks


VS 2019 Community Excel interop in Microsoft 365

$
0
0

I used to interop with excel through C#. But after installed the latest version of Microsoft Office (now Microsoft 365) I got this error when I try to open excel:

System.InvalidCastException: 'Unable to cast COM object of type 'Microsoft.Office.Interop.Excel.ApplicationClass' to interface type 'Microsoft.Office.Interop.Excel._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}'

These are the references:

This is the path for Microsoft.Office.Interop.Excel :

C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Excel.dll

Can you help me to know, what I'm doing wrong?

Thanks in advance

Carlos.

How to declare base class of ThisDocument ?

$
0
0

Hi all,
I want to put some base functionality into a base class where all my documents inherit from.
The question is how to declare this base class ??
I tried with partial, abstract... but always get the error "Base class of mynamespace.ThisDocument differs from declared in other parts" ??

Thanks for some help!
acki4711

how to retrieve values from different sheets in excel

$
0
0

Cheers

I am new to VSTO with VB.net and I want to learn basic things.

I need to know how to declare a variable that stores the collection of all sheets in an excel book and then be able to retrieve data from those sheets.

The next code don not works

Dim Shojas As Excel.Worksheet = Globals.ThisWorkbook.Worksheets

then I want to retrieve data from those sheets :

For k = 5 To Shojas.Count '

            Dim fima As Integer = Me.Application.ActiveWorkbook.Sheets(k)
            Dim fimo As Integer = Shojas.Item(k).Cells(2, 31)
            Dim fieq As Integer = Shojas.Item(k).Cells(3, 31)
            Dim ffma As Integer = Shojas.Item(k).Cells(1, 32)
            Dim ffmo As Integer = Shojas.Item(k).Cells(2, 32)
            Dim ffeq As Integer = Shojas.Item(k).Cells(3, 32)
            Dim fitr As Integer = Shojas.Item(k).Cells(4, 31)
            Dim fftr As Integer = Shojas.Item(k).Cells(4, 32)
        Next k

Thanks for your help.

why ribbon disappear?

$
0
0

I am using the professional visual studio 2019 latest version, I am building vsto office addin
A few minutes ago the project suddenly crashed after I added and deleted the image to some controls on the ribbon, and the project couldn't build. after a few minutes it built again but the ribbon disappeared for no apparent reason.
please help me!

Remote script execution gets blocked in a server component when accessed by a Word process via COM

$
0
0

I've developed a document generator as a VSTO-based word AddIn that reads its data from a system engineering tool (i.e. PTC Integrity Modeler). Some of the model properites in the engineering tool are derived at runtime via VB scripts. Since Office version 1806, remote script execution gets blocked when the Word process tries to read model data via the COM interface of system engineering tool.

Is it possible to allow this remote script execution for a specific process or component?

I can provide a simple test component to reproduce this behavior (without the need to install the system engineering tool): a DLL that evaluates a formula via a VB script; when it's called from another VB-Script it runs correctly, whereas when it's called from a Word VBA environment it doesn't....

Add item to second context menu of pictures (Word, Office 365)

$
0
0

Hello everyone,

I ask myself how to add a button to the additional (see picture below) context menu of a picture inside a word document with a C# VSTO Add-In. 

Has anybody done this before?

Thanks a lot,

Daniel

VSTO Excel Add-in does not load

$
0
0

I have been working on a pair of Excel add-in for over a year.  They were developed using Visual Studio 2017 using VSTO and have run on dozens of user computers under Excel 2010, 2013 and 2016 without a problem.  I've run it on a handful of other computers.

Recently, I got a new computer (Windows 10 64 bit; MS Office 365) and the add-ins do not load.  (Well, the machine has 2 users.  One user can run add-in A but not B and the second user can run B but not A.)  This is the same environment as another computer where the add-ins both run fine.

Both add-ins have the required registry keys (under Computer\HKEY_CURRENT_USER\Software\Microsoft\Office\Excel\Addins)

They do not show as disabled or in the list of add-ins known to Excel at all.

Environment var VSTO_SUPPRESSDISPLAYALERTS is set to 0 but no information appears on the screen.

There's nothing in the Event Viewer.

Fusion logging didn't show any relevant issues.

I've tried reinstalling the add-ins; repairing Excel.

What can I do to figure out what's going on here?



How to handle Open and Save event from PowerPoint Web Add-in

$
0
0
We are new to web add-in development. We need to create a PowerPoint web add-in and handle the PowerPoint “Open” and “Save” events. In Microsoft documentation we found a tutorial to create a PowerPoint task pane add-in. Unfortunately, in this tutorial, it is not mentioned about the PowerPoint “Open” and “Save” event. We have researched for a tutorial that meets our requirements. But we couldn’t find a proper tutorial. If anyone has any idea about the PowerPoint web add-in, please guide us. It would be very helpful for us. 

Add item to Mini-ToolBar of pictures (Word, Office 365)

$
0
0

Hello everyone,

I ask myself how to add a button to the additional (see picture below) ToolBar of a picture inside a word document with a C# VSTO Add-In. 

I used the "Accessibility Insights for Windows"-Tool (see https://accessibilityinsights.io/docs/en/windows/overview) to check the type of this menu. It gives me the information, that this menu is a ToolBar. 

Unfortunately, this ToolBar is not in the list of command bars I get with:

Application.ActiveDocument.CommandBars

Does anybody know how to get access to this ToolBar?

Thanks a lot,

Daniel



Script execution gets blocked in a server component when accessed by a Word process via COM

$
0
0

I've developed a document generator as a VSTO-based word AddIn that reads its data from a system engineering tool (i.e. PTC Integrity Modeler). Some of the model properites in the engineering tool are derived at runtime via VB scripts. Since Office version 1806, remote script execution gets blocked when the Word process tries to read model data via the COM interface of system engineering tool.

Is it possible to allow this remote script execution for a specific process or component?

I can provide a simple test component to reproduce this behavior (without the need to install the system engineering tool): a DLL that evaluates a formula via a VB script; when it's called from another VB-Script it runs correctly, whereas when it's called from a Word VBA environment it doesn't....


How to start inking mode in word build 12527.20194

$
0
0
 

I've developed a VSTO Addin for Word a few yeas ago. It uses the ink tool, so the user can write a signature directly on the document. I coded it in Visual Basic, because as of the time I didn't knew it better. Today i would take C#. I'm not a professional.


How it works

 1. When the user opens a document, the addin looks for a certain keyword. It has about 30 chars and is hidden in the document.
 2. If the keyword is found, it scrolls to the signature field and starts the inking tool, so the user can place the signature with a pen (prefered) or finger.
 3. When the document is closed, it will be automatically uploaded to a server where it is stored as a pdf.

So: Open - Signate - Close. No other interaction is required.

The weak point is, I use CommandBars.ExecuteMso to do this. Now and then Microsoft changes something 
in the Ribbon Tab.


I've used this in the last years

For Word 2010 and 2016

    Application.ActiveDocument.CommandBars.ExecuteMso("InkingStart")

For Word 365 - build 1803

    Application.ActiveDocument.CommandBars.ExecuteMso("DrawInkMode")

For Word 365 - build 1806

    Application.ActiveDocument.CommandBars.ExecuteMso("FingerPaintingMode")


Unfortunately it doesn't work anymore since build 12527.20194 (https://support.office.com/en-us/article/what-s-new-in-microsoft-365-95c8d81d-08ba-42c1-914f-bca4603e1426?ui=en-US&rs=en-US&ad=US)

In this build they added a lasso tool. When I execute CommandBars.ExecuteMso("FingerPaintingMode"), the lasso tool is active and not the pen.

https://i.stack.imgur.com/YQk1b.png

You can execute this code as VBA in Word to see what i mean.

    Sub InkTest()
        Application.ActiveDocument.CommandBars.ExecuteMso ("FingerPaintingMode")
    End Sub

The weird thing is, when you physically click on FingerPaintingMode, the pen is active and not the lasso.
https://i.stack.imgur.com/0q0Em.png

I think of two possible solutions


 1. Use a ink object directly and don't go over the ribbon. My preferred option, but im unable to find a way for this. https://docs.microsoft.com/en-us/office/vba/api/overview/word/object-model
 2. Select a Pen in the InkToolbox in the TabDrawInk tab. But it's a control type. So I can't use ExecuteMso. How could I do that?

PowerPoint Add-in for both OneDrive and Microsoft Teams files

$
0
0
We are new to Office 365 (OneDrive Business Account).  In Office 365 account, when we open a presentation under OneDrive, it directly opens in the web browser. But when we open a presentation under the channel in Microsoft Teams, it opens in an add-in inside the Team.

We have to handle some operations when a user opens a presentation using any of the above scenarios. So we are planning to create a  PowerPoint Web add-in to achieve this. We are not sure whether if we go with a web add-in, will it work on both cases?  Please guide us if we are wrong. We have researched, but couldn’t figure out proper documentation.

VBA: Start inking in Word

$
0
0

How do I start inking in Word build 12527.20194?

1st) This works for Word 2010 and 2016

Sub InkTest()
    Application.ActiveDocument.CommandBars.ExecuteMso("InkingStart")
End Sub

2nd) This works for Word 365 - build 1803

Sub InkTest()
    Application.ActiveDocument.CommandBars.ExecuteMso("DrawInkMode")
End Sub

3rd) This works for Word 365 - build 1806

Sub InkTest()
    Application.ActiveDocument.CommandBars.ExecuteMso ("FingerPaintingMode")
End Sub

Unfortunately 3rd doesn't work anymore since build 12527.20194 (https://support.office.com/en-us/article/what-s-new-in-microsoft-365-95c8d81d-08ba-42c1-914f-bca4603e1426?ui=en-US&rs=en-US&ad=US)

In this build they added a lasso tool. When I execute CommandBars.ExecuteMso("FingerPaintingMode"), the lasso tool is active and not the pen.

The weird thing is, when you click on the FingerPaintingMode button, the pen is active and not the lasso.

Create E-Mail using Interop is stuck in outbox

$
0
0

From a WPF application I create a MailItem like so:

var outlook = new Application();
var ns = outlook.GetNamespace("MAPI");
var mailItem = outlook.CreateItem(OlItemType.olMailItem);
mailItem.DeleteAfterSubmit = false;
var sentFolder = mailItem.Application.Session.GetDefaultFolder(OlDefaultFolders.olFolderSentMail);
if (sentFolder != null)
    mailItem.SaveSentMessageFolder = sentFolder;
mailItem.Display(false);

When outlook is already running before the code above got executed and the user clicks send, everything works fine.

But if outlook has not been running, the message is stuck in outbox after the user clicks send.

In my research I found that this seems to be a common problem (e.g. here).

What is the proper way to ensure that messages are being send properly? Do I have to use SyncObject? Is there a complete code example available?

Or is it the best way to ensure that Outlook is always running?

Code is not downloaded in Visual studio 2017 from Azure Devops

$
0
0

Hi,

I have tried to connect one of solution from Azure DevOps when new Visual Studio 2017 has been installed on my machine.

It has been added, but showing as "Not Downloaded", I have tried getting latest, mapped to local folder too...but no success.

You can see in "Latest" column


'

Please assist.

Thanking you in advance.

Regards,

Jayashri

Bug when attempting to customise Outlook ContextMenuContactCardRecipient

$
0
0

Either there is a serious bug in the ContextMenuContactCardRecipient extensibility point, or some kind of refresh/invalidate call is required which I have not been able to find documented anywhere.

Consider the following ribbon XML which adds an item to the context menu that is shown when clicking on a Contact name (e.g. in the From field of a message):

<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="CustomRibbonUI_Load">

<contextMenus>
<contextMenu idMso="ContextMenuContactCardRecipient">
<dynamicMenu
id="ContextMenuContactCardDialMenu"
label="Dial Number"
imageMso="DialMenu"
getContent="ContextMenuContactCardDialMenu_GetContent"
invalidateContentOnDrop="true"
/>
</contextMenu>
</contextMenus>

</customUI>

The above works fine, until a message is double-clicked and opened in a new window, then the Inspector is closed. Once the inspector is closed, the customization is ignored for that Explorer window, even when the selection changes (the menu item is displayed empty and missing the icon). Opening a new Explorer window will allow it to work, again until a message is opened and closed. It also continues to work fine from Inspectors, but not that specific Explorer. I have confirmed this behaviour exists back to Outlook 2013 and attempting to call Invalidate or InvalidateControl on the ribbon  (e.g. when an Inspector is closed) has no effect.

This effectively makes the ContextMenuContactCardRecipient extension point useless as the behaviour is unreliable and confusing.

Is there something I'm missing? It's as if Outlook should be re-creating a new IRibbonExtensibility object in this instance, but it's not. The IRibbonExtensibility object does have ComVisible(true) by the way.

I suspect some kind of garbage collection problem (something getting collected or going out of scope which should not be) but I have been able to reproduce it in a very simple solution which does nothing apart from creating the menu item, which makes me think the bug is in the VSTO libraries...


Prevent actions to be added to the word undo redo OR Remove actions from the undo redo CommandBarComboBox

$
0
0

We are inserting content controls programmatically and we dont want to add actions to the undo stack of word. The only way that we found is to acess the undo command bar combox and to remove the items related to inserting content control action, we are using the code below :

var commandBars = _wordDocument.CommandBars.Cast<CommandBar>();
            var standardCommandBar = commandBars.First(bar => bar.Name.Equals("Standard"));
            CommandBarComboBox undoControl = standardCommandBar.Controls.Cast<CommandBarControl>().First(control => control.Id == 128) as CommandBarComboBox;

undoControl.RemoveItem(1);

The last line (undoControl.RemoveItem(1)) throws a ComException (HRESULT E_FAIL).

Is there any way to remove actions from the undo redo combo box?

Regards.

VSTO Outlook Schedule Assistant Recipient working hours

$
0
0

Good day,

May I please ask if it is possible to 

Get Outlook Schedule Assistant Recipient working hours in code.

C# or VB.

I am not finding from Outlook.AppointmentItem.

Thank you in advance.

Add context menu item for Outlook 2016

$
0
0

I am trying to add an item to the context menu when a user right-clicks inside an email message. I have wired up handlers for the following events, none of which seem to get fired when I right-click while debugging (I have breakpoints set inside each of them):

Application.ViewContextMenuDisplay += OnViewContextMenuDisplayHandler;
Application.FolderContextMenuDisplay += OnFolderContextMenuDisplayHandler;
Application.ItemContextMenuDisplay += OnItemContextMenuDisplayHandler;

What could be causing the event not to get fired? Am I not using the right event? Or is this not even the correct approach for adding a context menu item?

Viewing all 5157 articles
Browse latest View live


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