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

Need to create a local keyboard hook to bind a keyboard shortcut with Outlook Add-in.

$
0
0
Need to create a local keyboard hook to bind a keyboard shortcut with Outlook. I am creating an outlook VSTO add-in in C#. So far i am able to create global keyboard hook. But the shorcut triggers the event from other applications as well other than Outlook. Is there any way to create a local one instead of a global hook?

Convert Data from Excel to XML when schema includes 'list of lists'

$
0
0

Hi,

 

I am trying to convert a complext spreadsheet from excel to a XML. Also beacuse of the requirements of the destination application requirement i need to follow the specific schema.

 

I was able to map all the elements in excel spreadsheet and export the spreadsheet in the required xml format. But the problem starts when there is a 'List of List' in the XML data. and the data is not normalized. when i am truing to map the child of child , i am not able to retain the relationships.

 

I know with .net  it is possible to build a application from scracch to do it. but with the time and application contraint, is there a way to handle this mapping of excel data?

 

Thanks

Kedar Adavadkar

Signing a VSTO Outlook add-in with a certificate

$
0
0

So we have a VSTO add-in for Outlook 2013, it has a self-signed certificate from Visual Studio/Something by the developer. But using this certificate means the installer still prompts with the:

Publisher cannot be verified.

..........

Publisher: Unknown Publisher

So rather than using the self-signed certificate I wanted to issue a certificate from our domain CA, does anyone have any instructions for this? What type of certificate? Do I issue it to the add-in manifest name or something else? Etc...

I need the publisher to not be unknown or the silent switch on vstoinstaller.exe doesnt work.

Unable to see my custom pane

$
0
0

Dear all,

I am just started to test the custom pane, and even if I have follow the very instructive msdn tutorial How to add a custom task pane to an application bur my custom pane doesn't show up !!!I'm usint VSTO 2010 & Excel 2010.

My code is exactly the same than the tutorial :

Public Class ThisAddIn
    Private myUserControl1 As MyUserControl
    Private Sub ThisAddIn_Startup() Handles Me.Startup
        myUserControl1 = New MyUserControl
        Dim myCustomTaskPane As Microsoft.Office.Tools.CustomTaskPane = _
            Me.CustomTaskPanes.Add(myUserControl1, "My Task Pane")
        myCustomTaskPane.Visible = True
    End Sub

    Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown

    End Sub

End Class

When I press F5 I was expecting to have the MyUserControl display but nothing happen ...

I really dont know why...

Could someone help me ?

Thanks in advance

BR

Guillaume

GetProperty(PR_SECURITY_FLAGS) returns 65532 on mailItem. Why this value

$
0
0

I am using the property accessor of a mailItem object to check if the mailItem is encrypted or not.  I am expecting a result of 0 or 1 but sometimes I am getting a returned property of 65532.

Can sombody indicate to me why

GetProperty(PR_SECURITY_FLAGS)

returns 65532?

Dim oProp As Long Dim oPropAcc As Outlook.PropertyAccessor = Nothing oPropAcc = mayMailItem.PropertyAccessor oProp = CLng(oPropAcc.GetProperty(PR_SECURITY_FLAGS))


myworkbook = Workbooks.Open(strfile) works on form, but don't work in a class

$
0
0

 myworkbook = Workbooks.Open(strfile) works on form, but don't work at inner  class

i can call the objects at the class from the form and work but when i want to usu that internaly they return 0x800a03ec

 

Visual Studio 2010 Tools for Office Runtime link broken?

$
0
0

Hi

When I try to download the Visual Studio 2010 Tools for Office Runtime  from http://download.microsoft.com/download/9/4/9/949B0B7C-6385-4664-8EA8-3F6038172322/vstor_redist.exe  I end up getting a SquareSpace page that says, domain not claimed. 

Can this link be fixed or is there somewhere else to get the runtime from.

Cheers

Steve

Saving Current Powerpoint as WMV

$
0
0

Hi,

I have been asked to write a PowerPoint 2010 addin that converts the current presentation to a WMV file and FTPs it onto a remote server.

But I am having some problems finding out when the "file save" process has completed so I can then start the FTP.

This is the code I have so far:

using System;
using System.Windows.Forms;
using Office = Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using System.IO;

namespace PowerPointAddIn2
{
    public partial class LoginPanel : UserControl
    {
        public LoginPanel()
        {
            InitializeComponent();
        }

        private void LoginPanel_Load(object sender, EventArgs e)
        {

        }

        private void btnLogin_Click(object sender, EventArgs e)
        {

            string exportName = "video_of_presentation";
            string exportPath = @"C:\{0}.wmv";
            // Export the currently open presentation
            PowerPoint.Application ppApplication = null;
            ppApplication = new PowerPoint.Application();
            ppApplication.Activate();
            ppApplication.ActivePresentation.SaveAs(String.Format(exportPath, exportName), PowerPoint.PpSaveAsFileType.ppSaveAsWMV, Office.MsoTriState.msoTrue);

            //checkfile(exportPath, exportName);

            //MessageBox.Show("Finished");

        }

        protected void checkfile(string exportPath, string exportName)
        {
            FileInfo f = new FileInfo(String.Format(exportPath, exportName));
            while (IsFileLocked(f) == true) { System.Threading.Thread.Sleep(5000); }
            MessageBox.Show("Finished");
        }

        protected virtual bool IsFileLocked(FileInfo file)
        {
            FileStream stream = null;

            try
            {
                stream = file.Open(FileMode.Open, FileAccess.ReadWrite, FileShare.None);
            }
            catch (IOException)
            {
                //the file is unavailable because it is:
                //still being written to
                //or being processed by another thread
                //or does not exist (has already been processed)
                return true;
            }
            finally
            {
                if (stream != null)
                    stream.Close();
            }

            //file is not locked
            return false;
        }

    }
}

The problem I have is that if I uncomment the code that checks if the file is locked the process that saves the file as a wmv never seems to start so it just keeps checking and checking going in a loop.

If I leave the code exactly as above, with the file check not in there it works perfectly.

Can anyone suggest how I can tell when the file has finished being written so I can trigger the FTP code please?

Thanks

Trev


Convert from Excel/Visio 2010 to Excel/Visio 2007

$
0
0

I have created a VSTO addin for Excel 2010 and another for Visio 2010, using SQL SERVER 2008 R and stored procedures.

A prospective client uses Office 2007 and is not sure (yet) which version of SQL SERVER he has.

Should I expect to have to create another version of the programs specifically for Office 2007 and his SQL Server,  or should it work?

Is there some sort of automatic conversion maneuver?

Thanks,

Gina


Gina

Open .pdf stored in the same path as workbook

$
0
0

Hello:

I have a pdf file that I would like to open on a button click. The file will be located in the same path as the opened workbook. I worked out the following code but is not working. I am pretty sure I am missing a lot more code.

Option Explicit On
Option Strict On

'Libraries to use
Imports System.Drawing
Imports System
Imports System.IO
Imports System.Drawing.Printing
Imports System.Windows.Forms
Imports Microsoft.Office.Tools

    Private Sub btnRptEmployeePayToMarket_Click(sender As Object, e As EventArgs) Handles btnRptEmployeePayToMarket.Click


        Dim xlsWB As Excel.Workbook
        Dim xlsWBPath As String

        xlsWB = CType(Globals.ThisWorkbook.Application.ActiveWorkbook, Excel.Workbook)
        xlsWBPath = xlsWB.Path()

        Application.Documents.Open(FileName:=xlsWBPath & "\Employee Pay to Ranges.pdf", ReadOnly:=True)


    End Sub

Because I have Option Strict On, the Application is not allowed.

[Excel]Need to Track ExcelWorkBook Opening Event From a vsto addin

$
0
0
I need to show the custom ribbon created using vsto when some template is open in excel file? So that I am thinking to do it find out some range in the template if it is existing show the ribbon. For that i need to track WorkBook Staring event...Is there any way to do it?????

Best place to bootstrap Dependency Injection kernel

$
0
0

Hello,

I am supporting a VSTO Excel AddIn, and I'd like to find out the best place to bootstrap our Dependency Injection Kernel (Ninject).

For instance, the best place I could find so far is when the ribbon(s) are created, because this happens before the Startup event, if you can believe that.

We'll initialize our object graph at that point and inject into the ribbon itself, and places in the AddIn itself, with appropriate separations of concerns.

Is there an event that happens before that that we could monitor?

Thanks...

Regards,

Michael

Excel Workbook ClickOnce Deployment ERROR : Customized functionality in this application will not work because the certificate used to sign the deployment manifest for ExcelWorkbookTest1 or its location is not trusted

$
0
0

Hi !

I'm a newbie in VSTO Workbook Deployment using ClickOnce.

I've create a simple Excel Workbook and i publish it to url.

Then, i try to to browse that url http://test/ExcelWorkbookTest1.xlsx.

And , it throws an error

System.Security.SecurityException: Customized functionality in this application will not work because the certificate used to sign the deployment manifest for ExcelWorkbookTest1 or its location is not trusted. Contact your administrator for further assistance.

When i searched around the solution for that error, someone suggested to Configure Inclusion List Securityhttp://msdn.microsoft.com/en-us/library/bb772070.aspx

So I created those registry key on the machine that host the published xlsx and vsto file.

However,  the error still show up .

Then, I searched around for more information, and someone suggested to import the certificate to a file and run a certmgr command on client pc

Example :

certmgr -add ExcelWorkbookTest1Certificate.cer -s Root
certmgr -add ExcelWorkbookTest1Certificate.cer -s TrustedPublisher

I did that and still the same error show up.

Can anybody help me how to simplify the deployment?

Maybe I don't really understand it exactly what happen.

What is the .vsto file for after publishing the workbook project?

What is the .exe file for after publishing the workbook project?

Thanks

guk ugk


GUKGUK

Excel VSTO sheet codenames

$
0
0

When creating Excel programs with VBA, one of the key things for keeping the code robust is to use sheet codenames, which prevents the user from breaking the program the moment he/she decides to rename the sheet and move the order of sheets like when he/she has worksheets "a" and "b" and then rearranges and renames them to be "bananas" and "apples". Basically those codenames are like names of sheets while those users sees are captions.

Now when using VSTO, I have understood you are not supposed to use sheet codenames. So in order to make the code robust like with VBA, you need to...?

To give a code example, in VBA the wrong style (for setting the value of cell A1 to 1) is

Worksheets("Sheet1").Range("A1").value = 1

and the right style is

Sheet1.Range("A1").value = 1

In VSTO, the wrong style is

Worksheets("Sheet1").Range("A1").value = 1

and the right style is...?

UndoRecord not showing up in Word's undo list

$
0
0

I'm developing using C# and VSTO 4.0 and in VS 2010, using F5 (start debugging) to test my Word app-level AddIn.

That launches Word 2010.

My add-in works nicely, except that UndoRecord.StartCustomRecord/EndCustomRecord doesn't show anything on the Word undo list, just the atomic actions it would ordinarily show there (eg VBA-Paragraphs.Add).

I can see: 

ur.CustomRecordName->MyRecordName
ur.CustomRecordLevel->1
ur.IsRecordingCustomRecord->True

and after EndCustomRecord 

ur.CustomRecordLevel->0
ur.IsRecordingCustomRecord->False

And yet, MyRecordName never shows up in the undo list.

No exception or anything, what could be going wrong?!

thanks .. Jason


I would like get the "TO" information of an email with VSTO 2010

$
0
0

Hi,

     I have make an button who save as the email who are select in a folder.

When the email come from the inbox the button save as include in the name of the file, the name who are in the FROM section.

All work greet, I use the command below:

mailItem.SenderName; This command give to me a string than I could use to add in the name of my file during the SaveFileDialog process.

If I change the folder in Outlook to go in the sentmail, I would like make the same things, but with the name in the "To:" section of the select email...

Here is my trouble, I have use the command below:

mailItem.ReceivedByName;

But my string stay empty... How can I extract the name of my "TO" section when this mail is already save in my sentbox ??

thank you !

Customized Email Body for Outlook

$
0
0

How can I design HTML based email body for Outlook, kindly just guide me that how can I add HTML code in VB code that and that code create body of Outlook email message.

Or

On other end, is there any possiblity that I use an HTML page saved in my computer as outlook email body, that when I click on command button using VB application, program call that particular HTML page (saved in my computer) and display it in Outlook email body.

I want to use this HTML code or Call function for olMail.Body=

            ''''''''''''''''''' Start Outlook''''''''''''''''''
            ' If it is already running, you'll use the same instance...
            Dim olApp As Outlook.Application
            olApp = CreateObject("Outlook.Application")

            ' Logon. Doesn't hurt if you are already running and logged on...
            Dim olNs As Outlook.NameSpace
            olNs = olApp.GetNamespace("MAPI")
            olNs.Logon()

            ' Send a message to your new contact.
            Dim olMail As Outlook.MailItem
            olMail = olApp.CreateItem(Outlook.OlItemType.olMailItem)
            ' Fill out & send message...
            olMail.To = IU68_IL33_EvaluationsTableAdapter1.QuaryAgentEmail(ID)
            olMail.CC = IU68_IL33_EvaluationsTableAdapter1.QueryTLEmail(ID)
            olMail.Subject = "DiGi Evaluation"olMail.HTMLBody = ""            olMail.Display()

            ' Clean up...
            'MsgBox("Emails sent successfully", MsgBoxStyle.Information, "Done")
            'olNs.Logoff()
            olNs = Nothing
            olMail = Nothing
            olApp = Nothing
            ''''''''''''''''''' End Outlook''''''''''''''''''

Below is snapshot of HTML template that is saved in my compute and I want to call it inolMail.HTMLBody = ""


 

Dependency Injection in VSTO and Excel Add-in fail to load

$
0
0

Hi

I'm working in a VSTO2010 Excel solution and I'm trying to configure DI 

I'm working in VS2012

in the app.config I have

<configSections>
    ...
    <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration" />
  </configSections>

...

<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
    <alias alias="IContext" type="Models.DataInterfaces.IContext, Models" />
    <alias alias="Context" type="DataAccess.Context, DataAccess" />

    <alias alias="IRepositoryFactory" type="DataInterfaces.IRepositoryFactory, Models" />
    <alias alias="RepositoryFactory" type="DataAccess.RepositoryFactory, DataAccess" />

    <alias alias="ILogger" type="Unity.ILogger, Base" />
    <alias alias="Logger" type="Unity.Logger, Base" />

    <container>
      <register type="IContext" mapTo="Context">
        <lifetime type="PerThreadLifetimeManager" />
      </register>
      <register type="IRepositoryFactory" mapTo="RepositoryFactory">
        <constructor>
          <param name="context" />
        </constructor>
      </register>
    </container>
  </unity>

and I put 

        private void RegisterUnityContainer()
        {
            UnityContainer container = new UnityContainer();
            UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
            section.Configure(container);

            Registry.DependencyLocator = new UnityDependencyLocator(container);
        }

in ThisAddin.cs , and I call this method in the ThisAddin_StartUp 

when I try to load the Add-in in Excel 2013, a message says : "Not Loaded, a runtime error occured during the load COM Add-in"

I'm not sure if the DI is causing the error, or if the Repository pattern implementation is the cause or something else.

please, can you help me and tell me if the DI is correct configured, or how can I figure out what is causing the Add-in fail to load ?

thank you

activate a worksheet by index

$
0
0

I have a winform with a forward and a backwards button. What I am trying to do is to allow the user to move back and forth on the workbook by clicking on the button. I thought that the best way to achieve this is by using index. I worked out the code below, but because I have Option Strict On, it tells me that it cannot allow late binding.

the error is here:

WB.WorkSheets(WS.Index -1).Activate()

I am not really sure how I can change my code.

here it is:

    Option Explicit On
Option Strict On

'Import Libraries
Imports Microsoft.Office.Tools.Excel
Imports System.Drawing
Imports System
Imports System.IO
Imports System.Drawing.Printing
Imports System.Windows.Forms

Public Class frmNavigation

    Dim WB As Excel.Workbook
    Dim WS As Excel.Worksheet


    Private Sub btnMoveBack_Click(sender As Object, e As EventArgs) Handles btnMoveBack.Click

        'This event is triggered when the Previous Sheet button is
        'clicked. The sheet moves to the previous sheet. This event
        'is only run throughout the clientworksheets as the tabs and other
        'standard excel navigation may be disabled.

        WB = CType(Globals.ThisWorkbook.Application.ActiveWorkbook, Excel.Workbook)
        WS = CType(WB.ActiveSheet, Excel.Worksheet)

        WS.Application.ScreenUpdating = False



       WB.WorkSheets(WS.Index -1).Activate()()                              

        WS.Application.ScreenUpdating = True


    End Sub

Enable and Disable controls in a Ribbon

$
0
0
Good morning all,

I am developing an Outlook Addin which consists mainly of a Ribbon with two tabs.
One of the tabs has a ControlId as "TabMail" and the other tab has a ControlId as "TabReadMessage". I would like to enable and disable the controls on the Ribbon under certain conditions.

I did manage to achieve this for the "TabMail" tab by invalidating the controls and then issuing the Enable true or false. However, for some reason, I am not managing to enable/disable the controls under the "TabReadMessage" tab. 
Any suggestions for a potential solution or what might be happening?

Please note that I used the designer and not direct xml.

Thanks a lot!

Viewing all 5157 articles
Browse latest View live


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