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

How to programaticaly open files in microsoft power point from google drive, dropbox, MS oneDrive from web browser in C#

$
0
0

i am working on vsto application for opening ppt file in the MS power point. i am working on the client requirement in which on browser if end user access the file in google drive, dropbox, One drive then it will open that file locally using my vsto application.

in short, i am tries to bridge the interoperability gap between VSTO application and cloud services using there own Web application (browser UI) . how i can achieve this task.

i tried this with google drive api, drop box api but its allow to get the file list programaticalyafter successful authentication. and i am able to download the files by hitting the API calls. but as per requirement, i need to get the PPT file open in my app after user click it on browser.

is there any kind of connector services present to bridge the gap between VSTO app and browser request/ response ?

i am using dot net framwork 4.5 c# VSTO for my project. any help appreciated.



Outlook vsto new Simplified Ribbon

$
0
0

Hi all,

is there a way to detect the new Outlook Simplified Ribbon, so the buttons in the RibbonTab can be removed of the Text?

Yours Nanno.

Is there a way to activate a certain Tab on the Ribbon?

$
0
0

I have a Word 2007 application level add-in that creates a custom tab on the ribbon ("MyTab").

I would like to write code in the DocumentOpen to force "MyTab" to be the current active tab when certain documents are in use. 

Is there a callback that will allow me to force a particular ribbon tab to be selected?

Retrieving recipients from MailItem without saving it

$
0
0


Hello,

I've registered to the MailItem Property changed event, so that I can make some action using the To/Cc & subject fields when the user is creating a new email.

The events works fine, but when I receive the event I then call mailItem.Recipients, I don't have all encoded recipients. I need to first to save the mailItem then the retrieved recipients are correct. 

My problem is that saving the mailitem create a entry in the draft folder. And then if the user cancel the email it stay in the draft folder, thus having a different behavior than the default behavior. I tried to change the email just after saving it, it works as the user then have a popup asking if he want to keep the change, but when replying "No" the email is still in the draft. The subject doesn't have this problem, it's always up-to-date when retrieving value from the mailitem.

Any idea on how to retrieve the recipients without saving the mail first ?

Thank you

Sample Code Request: Create a Custom Shape with text and properties set by default

$
0
0

Sorry, this is probably just me not knowing where to look for the answer, but I would like to create a plugin that allows me to easily create a shape in a document and add some text to it by default as well as set some other parameters (transparency, etc).

Is there some sample code to build a VSTO Word Plugin that does something similar.  Ideally I would have a custom "Rectangle Tool" creation tool similar to the image attached.

I can add a rectangle using the Shapes.AddShape, but have only figured out how to add a shape where the cursor is now.  I would like the user to be able to click the tool, have the pointer change (similar to when you create a shape now in the default way), and drag and drop a rectangle on the word document.

Can someone point me to the right API's to do this?


How to get Background Save Property of Powerpoint Application Object (Microsoft.Office.Interop.PowerPoint.Application Background Save Property) ?

$
0
0

Can someone tell me how to get the background Save property of a PowerPoint Application object which I get from Word Application object ? 
i.e Microsoft.Office.Interop.Word.Application.Options.BackgroundSave 

Like this can i get the BackgroundSave property of a PowerPoint application object ? If yes , can you show me how to get that ? 
Thanks in advance ,
Hari 


haraiharan.t



PowerPoint 2019 UI freezes while generating the slide thumbnail

$
0
0

We have a VSTO-based PowerPoint add-in that generates charts in slides. The add-in works fine in PowerPoint 2016 and older. In PowerPoint 2019 (Office 365 monthly updates channel), however, after generating the chart there's a noticeable time interval where the ribbon freezes. Looking closely one can see that PowerPoint seems to execute the following actions internally:

- execute all shapes manipulation commands

- render the slide

- issue some command to generate the slide thumbnail and block the UI updates while the thumbnail is generated

- update the UI

We can reproduce the issue with an add-in developed from scratch, however we can't seem to be able to attach the source code here. It seems the issue occurs only after manipulating a large number of text boxes (it does not seem to appear when only manipulating shapes).

What can we do to avoid this issue? Where can we get paid support?

Getting paid support

$
0
0
We need help with an Office add-in. How can we get paid support from Microsoft?

Excel VBA search

$
0
0

Hi I'm trying to create a simple search VBA script but get an error when reading the sheets.

Here's the code:

Sub searchdata()
Dim erow As Long
Dim ws As Worksheet
Dim lastrow As Long
Dim count As Integer

lastrow = Sheets("Resume-submissions").Cells(Rows.count, 1).End(xlUp).Row

For x = 2 To lastrow

If Sheets("Resume-submissions").Cells(x, 1) = Search.Range("B3") Then --> error occurs here (run-time error 424)
Search.Range("A11") = Sheets("Resume-submissions").Cells(x, 1)
Search.Range("B11") = Sheets("Resume-submissions").Cells(x, 2)
Search.Range("C11") = Sheets("Resume-submissions").Cells(x, 3)
End If

Next x
End Sub

How to insert a docVariable field without changing the Word source content?

$
0
0

Hi all,

in a recent project, I need to insert some kind of markers in the Word source document without changing the content/text. I end up using doc Variable to do that and it works until hitting the use case when track changing is enabled. When adding the doc Variable to the document, I need to specify a value, which should be the text of the range of a place of interest, e.g., a bookmark, in the source document, since I don't want to change the content. After adding the doc Variable to the range as a field, Word automatically replaces the range text with the doc Variable value, which is actually the same as the range text. However, when the track change flag is on, the color and style (e.g., underline) will be changed and modification on the source document is noticeable, as shown in the screenshot below.

Image

The followings are the related C# code. Note that the lines to add underline and change text color won't work for an unknown reason. Please let me know if there is a way to fix this issue or if anything is wrong or there is an alternative solution without using docVariable to achieve what I need. Thanks in advance!

wordDocument.TrackRevisions = false;

wordDocument.ActiveWindow.ActivePane.View.RevisionsFilter.Markup = WdRevisionsMarkup.wdRevisionsMarkupNone;

//suppose the current range is for the heading "ANALYSE DE MARCHE" and the marker we want to embed is "docVarName", i.e., the name of the docVariable

wordDocument.Variables.Add(docVarName, range.Text);

Object obj = range.get_Style();

wordDocument.Fields.Add(range, WdFieldType.wdFieldDocVariable, docVarName, true);

range.set_Style(obj);

range.Font.Underline = WdUnderline.wdUnderlineSingle;

range.Font.ColorIndex = WdColorIndex.wdDarkRed;

range.Fields.Update();





Problem with Word Addin not starting/loading

$
0
0

Hi

We have a package of Office Addins for Word, Excel, Powerpoint and Outlook, all for Microsoft Office 2010.
A couple of clients out of +500 has been getting problems starting/loading the AddIn for Word.
The AddIns for Excel, Powerpoint and Outlook all works.

In our investigation we have tried reinstall Office and also our package, but without success.
The Addins are all registered in the Local_Machine-part of the registry.
When we look in the registry HKLM we can see that the Addin has Loadbehavior 3 as it should.
All files from the package are in place and nothing seems to be missing.

When we start Word we can se that an attempt is made to start the AddIn, but when the UI is shown, our menu is missing.
We look in the Word configuration - Addins, and our AddIn is amongs the inactivated ones.

We open the dialog for COM-Addins and when we try to fill in the checkbox, information is shown in the dialog that the AddIn is not lodaed and the reason is a runtime error.
We can see that no code in our Addin is executed because no entries in our logfile is found.

What we also has discovered is that when we try to activate the AddIn in Word UI, a new registry key is created in the Current_User-part of the registry with a singel value for Loadbehavior set to 2.

I'm beginning to feel there is some lost registry-value set the interferes with the Addin or that some files are missing.

Where should I begin to look for the cause of all this?

Thanks


Best Regards Peter Karlström Midrange AB, Sweden

Capture Delete button event and perform action

$
0
0

Hi Team,

I am working on Outlook Add-in (C#) and trying to capture Delete button event so that I can perform customized action by our Outlook Add-in like displaying a popup/messagebox, here is the code-snippet I am using which is not working in Outlook 2007:

public ADXCommandBarButton adxDeleteButtonO2007;

            this.adxDeleteButtonO2007 = new ADXCommandBarButton(this.components);
            this.adxDeleteButtonO2007.Id = 478;
            this.adxDeleteButtonO2007.Click += AdxDeleteButtonO2007_Click;

private void AdxDeleteButtonO2007_Click(object sender)
        {
            Messagebox("Deleting...");
        }


So it will be really appreciate if anyone can help on this.

Thanks,

Mukesh Kumar

Receiving Null-Pointer From using Excelfunctions Microsoft.Office.Interop.Excel (NuGet)

$
0
0

Hello everyone,

I use excel functions of Microsoft.Office.Interop.Excel (NuGet) in C#.
(Please do not persuade me to use a different liberary )
The project throws an exception when opening an excel file.
This happens always after calling:

             eApp = new Excel.Application();

For example in here:

   eApp = new Excel.Application();
   eWorkBook = eApp.Workbooks.Open("E:\\test.xlsx"... );

also in here:

eApp = new Excel.Application();
eWorkBook = eApp.Workbooks.Open("E:\\test.xlsx",
    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing, Type.Missing, Type.Missing,
    Type.Missing, Type.Missing);


or in here:

 eApp = new Excel.Application();
 eApp.Visible = true;
 eApp.UserControl= true;

If I look depper in the initialized opbjet 'eApp' there is somthing written like:

        exception of type 'System.InvalidCastException' for every entrie.

I can use the compiled programm as long as I do not execute the excel opening method.

I tried this with an open Excel also.
I tried this with Excel 2013 and Excel 2016.
I tried this with VS2012 and VS2017.
I tried different version of Microsoft.Office.Interop.Excel
the already compilated .exe file starts at a different Computer, but not at my computer.

Thanks.

Problem: Created VSTO Add-in for MS Project, used VS InstallShield for Setup; Setup Runs, but Add-in Not Available

$
0
0

Hi,

New to this forum. I have created a VSTO add-in for MS Project. I followed the instructions (https://docs.microsoft.com/en-us/visualstudio/vsto/deploying-an-office-solution-by-using-windows-installer) to create an InstallShield setup program for add-in using the InstallShield that comes with VS2015.

All builds successfully.

I ran setup on my target laptop (which has MS Project installed). Setup ran without complaint.

I ran MS Project, and add-in does not show up, nor can I "find it" via MS Project|File|Options|Add-ins.

I need to get this setup thing working... Any help would be appreciated.

Thanks,

Doug

Hyperlink not inserted while replying from reading pane (through VSTO Addin Program)

$
0
0

Hi,

I have written a addin program using VSTO to add hyperlink to some specific words in the mail. This program add hyperlink when i am writing a completely new mail. But when i reply from reading pane it does not add hyperlink. However when i reply with full screen body then hyperlink get inserted.

I got to know that if the mail body format is plain text then hyperlink are not inserted, but while debugging when i checked the mailBodyFormat while replying from reading pane, it is equal to "HTML". So ideally hyperlink should be inserted. 

Below is the code i have written:

Outlook.MailItem mail = Item as Outlook.MailItem;
            

            if (mail != null)
            {
                bool isWordMail = mail.GetInspector.IsWordMail();
                Word.Document doc = mail.GetInspector.WordEditor;
                

                

                string Url = "https://www.google.com";

                
                List<String> acronyms = Properties.Settings.Default.AcronymList.Cast<string>().ToList();

                var errors = doc.SpellingErrors;
                var len = errors.Count;
                foreach (Word.Range error in errors)
                {
                    if(acronyms.Exists(x => x.ToUpper() == error.Text.ToUpper()))
                    {
                        
                        if(error.Hyperlinks.Count == 0)
                        {
                            Word.Hyperlink hp = error.Hyperlinks.Add(error, Url);
                            
                        }
                    } 
                }
            }

Could anyone please help me?

Thanks,

Rahul


How to insert a cover page in MS Word at the beginning of the document?

$
0
0

I need to insert a cover page into a Word 2016 document.
The building block is a cover page and has

    InsertOptions = (int)WdDocPartInsertOptions.wdInsertPage; //= 2

So far so good.

But VSTO can only insert so:

    buildingBlock.Insert(range);

It does insert in place of range.

The event `Application.ActiveDocument.BuildingBlockInsert` is not raised.

Using native insert cover page (tab insert --> cover page) does insert properly (and creates only one undo entry insert building block).     

// -----------------------------------------------------------------
// try 1
var range = Application.ActiveDocument.Range();
range.Collapse(WdCollapseDirection.wdCollapseStart);
buildingBlock.Insert(range);
// result: inserting on the existing first page
//         one undo entry
//         event BuildingBlockInsert has not been raised
// -----------------------------------------------------------------
// try 2
//object start = 0;
//object end = 0;
//var range = Application.ActiveDocument.Range(ref start, ref end);
//buildingBlock.Insert(range);
// result: inserting on the existing first page
//         one undo entry
//         event BuildingBlockInsert has not been raised
// -----------------------------------------------------------------
// try 3
//var range = Application.ActiveDocument.Range();
//range.InsertParagraphBefore();
//var p = Application.ActiveDocument.Paragraphs[1];
//buildingBlock.Insert(p.Range);
// result: inserting on the existing first page
//         two undo entries
//         event BuildingBlockInsert has not been raised
// -----------------------------------------------------------------


A similar problem is described in Note of:
https://docs.microsoft.com/en-us/office/vba/word/concepts/working-with-word/working-with-building-blocks#inserting-a-building-block-into-a-document

It seems VSTO ignores any insert options,
and there is no way to parameterize insert option by inserting.

How can VSTO insert a building block in a new first page as a Word native action?

I'm using VS 2017 Word 2016 Add-In, .Net Framework 4.6.1.




problems getting object/array from VSTO AddIn back to VBA

$
0
0

I have my AddIn's COM exposure back to VBA all working, including returning simple types from method calls, except for passing back something more complex, a VB Queue(of MyStructure).

' from ThisAddIn.VB/ThisAddIn class:
...
    Private VbaExposure As MyAppdataCom
    Protected Overrides Function RequestComAddInAutomationService() As Object

        If VbaExposure Is Nothing Then
            RequestComAddInAutomationService = New MyAppdataCom
        Else
            RequestComAddInAutomationService = VbaExposure
        End If

    End Function
...

'----------------------

' from a class in the AddIn project
<ComVisible(True)><InterfaceType(ComInterfaceType.InterfaceIsIDispatch)>
Public Interface IMyAppdata
    ReadOnly Property OpResults As Object
...
End Interface<ComVisible(True)><ClassInterface(ClassInterfaceType.None)>
Public Class MyAppdataCom

    Implements IMyAppdata

    Private ReadOnly Property IMyAppdata_OpResults As Object Implements IMyAppdata.OpResults
        Get
            IMyAppdata_OpResults = SharedState.OpResults
        End Get
    End Property
...

'----------------------

' from SharedState class
Public Structure OpResult
    Public ReadOnly Property Result As ResultsEnum
    Public ReadOnly Property Context As String
    Public Sub New(Result As ResultsEnum, Optional Context As String = Nothing)
        Me.Result = Result
        Me.Context = Context
    End Sub
End Structure
...
    ' used to pass operation result
    Public Shared OpResults As New Queue(Of OpResult)
...


I've tried it as-is wth VBA

Dim result As Object
Set result = MyAddIn.OpResults

and get Object required. I've also tried to return the VB Queue object.ToArray; same problem. And I've tried receiving the object.ToArray from VBA as a Variant. Also no go. And other variations and combinations I'm not remembering at the moment.

The documentation I've found for how to pass data from VB/VSTO back to VBA is sparse at best, possibly beyond my comprehension, and C# -centric.

Any suggestions or additional resources/example code would be greatly appreciated!

VSTO - Delete is not working

$
0
0

Delete() is not deleting the copy which was created

Microsoft.Office.Interop.Outlook.MailItem mailItem = (selObject as Microsoft.Office.Interop.Outlook.MailItem);
MailItem copy = mailItem.Copy();

// Some functionality

copy.Delete();

Can you please help?

Thanks, Amit

VSTO add-in form region not rendered

$
0
0

Hi,

we got the following issue in our VSTO add-in: a form region is loaded with correct title and size, but rendered empty (without the controls/widgets). There were two cases reported in Outlook 365 Business (Version 1811) by customers, and we can reproduce it ourself using that particular version, it apparently works correctly in Outlook 365 ProPlus (Version 1803), Outlook 2013 and Outlook 2016. Any help is appreciated.



Trying to Hide Custom Ribbon at Run-Time

$
0
0

Howdy,

I have a VSTO Add-In for MS Project. In the case of errors occurring that would cause the Add-In to not function properly (exceptions raised due to a corruption of a application data file for example), I want to hide the Ribbon for the Add-In.

I add the Ribbon by overriding "CreateRibbonExtensibilityObject" which calls a method "GetRibbon").

In cases where I want to hide the ribbon, I call "HideAddInUI".

Only problem is, it does NOT hide the Ribbon...

Anyone out there seen this before and figured out a way to solve the problem?

        IresRibbon _IresRibbon = null;
        protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
        {
            return GetRibbon();
        }
        private IRibbonExtensibility GetRibbon()
        {
            _IresRibbon = new IresRibbon();

            _IresRibbon.btnPriceMpp.Click += PriceProject;
            _IresRibbon.btnGenerateTOE.Click += GenerateTaskOrderEstimateReport;
            _IresRibbon.btnEditTaskOrder.Click += EditTaskOrder;
            _IresRibbon.btnGenerateJCJASCI.Click += GenerateJCJASCI;
            _IresRibbon.ddPricingSource.SelectedItemIndex = 1;

            return Globals.Factory.GetRibbonFactory().CreateRibbonManager(
                new Microsoft.Office.Tools.Ribbon.IRibbonExtension[] { _IresRibbon });
        }
        private void HideAddInUI()
        {
            Progress.Hide();

            _IresRibbon.tab1.SuspendLayout();
            _IresRibbon.tab1.Visible = false;
            _IresRibbon.tab1.ResumeLayout();
        }

Viewing all 5157 articles
Browse latest View live


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