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

decrypt message

$
0
0

HI all,

pls exist sample code for decrypt email stored in Inbox ? If the mail is opened I can run :

$mailitem.PropertyAccessor.SetProperty($PR_SECURITY_FLAGS, 1) 
$mailitem.save()
$mailitem.PropertyAccessor.SetProperty($PR_SECURITY_FLAGS, 0) 
$mailitem.save()

but if i try with this command decrypt unopened mail, the command return fail. the mail is encrypted with x509 certificate stored in the smartcard.

thanx


Falcon


Outlook - Operation Aborted Exception when adding an attachment through Attachments.Add

$
0
0

We have an integration the handles Application ItemSend event, to perform extra processing on the attachments remove them using Attachment.Delete and potentially re-adding them after processing using Attachments.Add.

We are experiencing an intermittent issue when adding attachments at different sites where programmatically adding an attachment fails with an Operation Aborted Exception. 

We are unable to reproduce this reliably in the production environments where the issue is occurring, but I have been able to reproduce it by creating another AddIn that handles the BeforeAttachmentAdd event and setting cancel to true .

I have a few questions I'd appreciate any help with.

1) What are the possible causes of an Operation Aborted Exception when calling Attachments Add?

2) Is there any way to trace which AddIns are handling specific events in Outlook or tracing any other interactions are occurring, as given the number of AddIns that are present and the different environments it's going to be time consumingto determine the cause in each environment.

3)  When the Operation Aborted Exception is thrown is there any way of determining what caused this?

In some cases we are able workaround this by using the PropertyAccessor to replace the content of the files - when the filename hasn't changed.

Unable to cast COM object of type 'System.__ComObject'

$
0
0

My project is to take a group of word 2003 documents and change the properties on them.  I am doing this by storing the path and the new properties in a SQL Server table and accessing it through my C# code.  The code opens the document just fine, but when it gets to this line in the code it throws a COM error.

 

properties = (Microsoft.Office.Core.

DocumentProperties)oDoc.Application.ActiveDocument.BuiltInDocumentProperties;

 

Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Core.DocumentProperties'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{2DF8D04D-5BFA-101B-BDE5-00AA0044DE52}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

 

My developement machine is running Vista with VS 2005 Team.  I have Office 2007 installed as well as Word 2003.  I have added the Microsoft Office 11.0 Object Library and the Microsoft Word 11.0 Object Library refrences. 

 

Here is the rest of the code I am trying.  I hope someone can help.  Thanks.

 

Code Snippet

using System;

using

System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

using

System.IO.Packaging;

using

Word = Microsoft.Office.Interop.Word;

using

Office = Microsoft.Office.Core;

using

System.Reflection;

.

.

.

 

object fileName = strFileLocation;

Word.Application oWord;

Word.Document oDoc;

object missing = Type.Missing;

object falseValue = false;

object trueValue = true;

oWord = new Word.Application();

oWord.Visible = true;

 

oDoc = oWord.Documents.Open(

ref fileName, ref missing, ref falseValue, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);

 

Office.

DocumentProperties properties;

 

properties = (Microsoft.Office.Core.

DocumentProperties)oDoc.Application.ActiveDocument.BuiltInDocumentProperties;

 

properties[

"Creator"].Value = Convert.ToString(row["Author"]);

properties[

"Title"].Value = Convert.ToString(row["Title"]);

properties[

"Subject"].Value = Convert.ToString(row["Subject"]);

properties[

"Description"].Value = Convert.ToString(row["Description"]);

properties[

"ContentStatus"].Value = Convert.ToString(row["Status"]);

properties[

"ContentType"].Value = Convert.ToString(row["DocType"]);

oDoc.Close(

ref oFalse, ref oMissing, ref oMissing);

 

 

Implement authentication mechanism to open power-point slides from Google drive using C#

$
0
0

We want to add powerpoint slides from google drive to existing slide programmatically. We are using powerpoint add-in project type from VS. Is there any way to achieve this?

I have below code which just redirects me to Gmail for login but not does anything after login.

What I have tried:

UserCredential credential;
using (var stream =
new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
{
string credPath = "token.json";
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
Console.WriteLine("Credential file saved to: " + credPath);
}

// Create Drive API service.
var service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});

full code is at link  https://developers.google.com/drive/api/v3/quickstart/dotnet

Ribbon designer and ribbon Xml

$
0
0

I want to add a context menu in outlook using ribbon designer .

I have implemented it using a ribbon Xml in a sample application.

I want to use only ribbon designer for the same because most of the previous code is already in designer is there a way to use my xml inside designer/ can i implement context menu using ribbion designer?

Can't save the same document for the second time

$
0
0
I Can't save the document for the second time .
Getting the below error  :
System.Runtime.Interopservices.COMException (0x800a1420) : this is not a valid file name

This is my code 
Word.Document document = Globals.ThisAddIn.Application.ActiveDocument;
object FilePath = @"E:\\Logs\\temp\\"+document.Name;
document.SaveAs(ref FilePath,
ref missing, ref missing, ref missing, 
ref missing, ref missing,ref missing, ref missing, 
ref missing, ref missing, ref missing,ref missing, 
ref missing, ref missing, ref missing, ref missing);

object SecondFilePath = @"E:\\Logs\\origin\\"+document.Name;
document.SaveAs(ref SecondFilePath ,
ref missing, ref missing, ref missing, 
ref missing, ref missing,ref missing, ref missing, 
ref missing, ref missing, ref missing,ref missing, 
ref missing, ref missing, ref missing, ref missing);

Set a FileStream object in post request body

$
0
0
Can someone help me to set a FileStream object in a request body to upload a file ?
or can you figure which is the right way to do so............?

Macro security warning prompted when my document is created by my add-ins

$
0
0

Hi,

I have a office add-ins which will add/update document properties for `document control`, but I found that "Macro security" warning will prompt on the document I created and updated by the add-ins under Office 2013.  And I tried that if my"Macro security" setting changed to "Disable all macros except digitally signed macros", the prompt will not shown when I open the file.

My add-in is just updating document properties, Word and Excel will prompt this warning but PowerPoint hasn't when "Macro security" under "Disable all macros with notification", so may I have any hints that how office determine the file is need to prompt or not?

Thanks.


calendarw


Set request body data and File in multipart form data POST Request

$
0
0
Hey There ....
I am trying set both request body data and FileStream in POST HTTP request.
But only the file is being added in request body , the POST BODY PARAMETERS are not added

string fileUrl=@"E:\code.txt"; string url = "http://ptsv2.com/t/PostReq/post"; // Create a http request to the server endpoint that will pick up the // file and file description. HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); string boundaryString = "------------"+DateTime.Now.Ticks.ToString("x"); // Set the http request header \\ request.Method = WebRequestMethods.Http.Post; request.ContentType = "multipart/form-data;boundary=" + boundaryString; request.KeepAlive = true; request.Credentials =CredentialCache.DefaultCredentials; // Use a MemoryStream to form the post data request, // so that we can get the content-length attribute. MemoryStream postDataStream = new MemoryStream(); StreamWriter postDataWriter = new StreamWriter(postDataStream); // Include the file in the post data postDataWriter.Write("\r\n--" + boundaryString + "\r\n"); postDataWriter.Write("Content-Dis-data;"+ "name=\"{0}\";"+ "filename=\"{1}\""+"\r\nContent-Type: {2}\r\n\r\n", "myFile", Path.GetFileName(fileUrl), Path.GetExtension(fileUrl)); postDataWriter.Flush(); // Read the file FileStream fileStream = new FileStream(fileUrl, FileMode.Open, FileAccess.Read,FileShare.ReadWrite); byte[] buffer = new byte[1024]; int bytesRead = 0; while ((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0) { postDataStream.Write(buffer, 0, bytesRead); } fileStream.Close(); postDataWriter.Write("\r\n--" + boundaryString + "--\r\n"); postDataWriter.Flush(); // Dump the post data from the memory stream to the request stream using (Stream s = request.GetRequestStream()) {

string data="username=hello&pwd=test123";

byte[] postData = Encoding.ASCII.GetBytes(data);

stream.write(postData,0,postData.Length);

postDataStream.WriteTo(s); } postDataStream.Close(); WebResponse response = request.GetResponse(); StreamReader responseReader = new StreamReader(response.GetResponseStream()); string replyFromServer = responseReader.ReadToEnd(); MessageBox.Show(replyFromServer);

Everytime I run the solution only the file is uploaded to server , not the post request body ,
Can someone help me to figure this problem ??

How to Save Outlook email as .eml file using add-in when it was in compose mode

$
0
0
I am developing an outlook add-in which should allow user to save the outlook email which is in compose mode as a .eml file and save it to Google Drive/Dropbox before sending. I was able to get the message body, cc, to, subject etc but unable to get the attachment. Is there a way I can get all the details of the Item including attachment using ItemId and save it as .eml file?
In compose mode on clicking send button I managed to get ItemId and using it the rest of the message data.

VSTO and Slow Excel Shutdown

$
0
0

Hello

I am building an Excel add-in using VSTO. It consists of a WPF control docked inside an Excel Actions pane. The WPF control is housed inside a Winforms ElementHost. The add-in is built using Visual Studio 2013 Update 4 and Excel 2013 and running on Windows 8.1

What I am finding is when Excel is shutdown, it takes around 20-30 seconds for the application to close. I have experimented with taking the WPF control out and have found it does not suffer from the slow shut down but I can't be 100% certain this is the cause. I was wondering if anyone else has experienced this problem?

Regards

Michael

vba Word: How to add selected text into right click menu, or add right clicked word in menu

$
0
0

I also have related question with above post

every thing is working fine but i want to add Selected text into right click menu as a .caption

here is my code

Public Sub CreateMacro()
Application.CommandBars("Text").Reset

    Dim MenuButton As CommandBarButton
    With CommandBars("Text")
        Set MenuButton = .Controls.Add(msoControlButton)
        With MenuButton
            .Caption = Selection.Text
            .Style = msoButtonCaption
            .OnAction = "Test_Macro"
        End With
    End With

    
End Sub

Public Sub Test_Macro()
    MsgBox "I work"
    ResetRightClick
    CreateMacro
End Sub

Sub ResetRightClick()
    
    Application.CommandBars("Text").Reset
End Sub

on first attempt right click menu is displayed but empty caption, and on next times it show older caption (not current selection) until the menu item is clicked

or how to add Right clicked word into right clicked menu

how to read presentationML and insert the output on the active slide in powerpoint using vsto c#

$
0
0

hello,  i just want to  store the presentaionML in a string then read that string and place the output of that presentationML to the active slide using powerPoint VSTO c#.  for e.g. string s = "presentaionML for Hello world in paragraph".  then on button_click event the Hello world should inserted on to current slide of presentation.  please anybody can help me on this?



Excel15.xlb

$
0
0

is it possible to change this file for different workbooks

Why when ThisAddIn.Application.Workbooks.Open(fullName) I lose the extension, is a bug in the model?

$
0
0

Hi all thank to read this,

Why when i use ThisAddIn.Application.Workbooks.Open(fullName) to open a excel file I lose the extension, for instance

if fullName = "xxx/xxx/xxx/file1.xltm" excel open the file, but if a look at the top of the excel where the name of the file is no extension there, then is imposible to get the extension of the file using FullName 

Is this a bug?


Calling an AfterSave Event when Ctrl+s is pressed

$
0
0
How to call an custom function code when Ctrl-S is pressed ?
I'm developing an VSTO Add-in ,when I press Ctrl+S  my own function has to be called after the native save call function .
Can someone help me with this thread ?

haraiharan.t

VSTO Outlook froze outlook when add-in is installed over network path.

$
0
0

Hello, 

I have an outlook addins that is installed to users from remote shared-drive. For most users it went ok, buy there are couple users who are located internationally that complains that the add-ins winform froze the PC for 30 seconds. I've looked at their machine and when I copy the vsto installer locally, everything seems ok. Is this normal? 

The add-ins take input from the user and then started three async threads that create multi-calendar events in separate users' calendars. I've also check call-stack and make sure there's no loose locks that requires marshalling. 

VSTS:ERROR:error facing while deployment of .Net application on azure service app

$
0
0

ERROR:

Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'myApp11111'. Error: Could not fetch access token for Managed Service Principal. Please configure Managed Service Identity (MSI) for virtual machine 'https://aka.ms/azure-msi-docs'. Status code: 400, status message: Bad Request

This error is encountered while depolying .Net application on azure app service using vsts/Azure Devops.

Publisher in customized Word COM ADD-IN

$
0
0

I am able to load VSTO word add-in but the Publisher is <none>.

I am giving the valid signing certificate in project properties. Any help?

Integration of C# VSTO Add-In and Xll UDF in Single Installation access each others memory

$
0
0

Hello,

Is there a way of creating UDF function in VSTO.
If not is there a way to interact between the VSTO and UDF created in XLL - both programmed in C#? Or can we create a managed function in C# and use it by adding the function via Add-in automation?

The VSTO Add-ins created has Login functionality to DB. My main concern is we need to use the function created in XLL =RefreshData() only after the user logs in.

But how to know if the user is logged in from UDF <g class="gr_ gr_225 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling" data-gr-id="225" id="225">xll</g>?

Thanks

Senthil



Viewing all 5157 articles
Browse latest View live


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