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

Document doc = wordApp.Documents.Add(ref LetterTempletePath, ref writepwdoc, ref filetype, ref addToRecentFiles); not opening the template

$
0
0

we are generate the word document and using the template

when it comes to this below statement it does not move to next step and not showing any exception and document generation not moving to next step

we reinstalled the MS office as well

Still document is not generating and got stuck in the below step

  Document doc = wordApp.Documents.Add(ref LetterTempletePath, ref writepwdoc, ref filetype, ref addToRecentFiles);


edwin


VSTO automatically adds namespace attribute to element when inserting a new repeating section.

$
0
0

<Company Xmlns:"http://mycompany"
<Person>
<name>Old name</name>
</Person>
</Company>

whenever I add a new repeating section ( person )

<Company Xmlns:"http://mycompany"
<Person>
<name>Old name</name>
</Person>
<Person Xmlns:"http://mycompany">
<name>New name</name>
</Person>
</Company>

how do I prevent that from happening? 

VSTO FOR WORD close invisible document will scroll to top

$
0
0

I try to paste a table copy from an invisible document to current document. But when I close the invisible document, it will make the current document scroll to the top. How to keep the position?

//In a button click event
var docT = XApp.WApp.Documents.Open(templatePath, ReadOnly: true, Visible: false);
// do copy and paste or just do nothing
docT.Close();//make the active document scroll to the top

VS 2019 Installation Set up issue

$
0
0

I get the below error when trying to install VS 2019. Could you please help.

Could not start Visual Studio due to the error.
System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
Inner Exception- 
System.Configuration.ConfigurationErrorsException:Unrecognized configuration section startup.
(C:\Users\XXXXX\AppData\Local\Microsoft\VisualStudio\15.0_028da718\devenv.exe.config line 13)

Is there *anything* that allows me to write Excel macros in F#?

$
0
0

I'm not even sure if this is the right category; sorry if it's not.

The question is in the title. Some mathematical calculations involving sequences aremuch easier to write in F# than VB (sometimes 1 long, wrapped line of F# is enough to create a sequence that in VB would involve considerably more work). I was wondering if Visual Studio Tools for Office would somehow allow me to do that (I don't think so, I think it is used to write Add-ins for Office Apps, but I don't really know much about it)? Or maybe there's already an extension out there (very well hidden from Bing searches...)?

I don't even want to access Excel itself from F#, I just to do all the maths in F#, and then use normal VB macros to consume the results or feed raw numbers to my F# code. All the event handling, dealing with cells and ranges, all that is quite easy to do in VB. I only wish to code the mathematical algorithms in F#.

Error: Unable to debug Windows Store app '#Software\Microsoft\Office\16.0\Excel\InstallRoot\Path#excel.exe'. The debugger was unable to find the registration for the target application.

$
0
0

I am trying to run an application that adds a COM add-in to Excel via VSTO. I have 64-bit Microsoft Office installed, am using latest version Visual Studio 2019 and am running solution using Debug-x64 build configuration. It compiles successfully. But, when I run it I see the above error.

My add-in would show up inside of the COM add-ins dialog in Excel, but if I check the box to show it/load at startup, it doesn't show up or load. When I reopen the COM add-ins dialog, the box is unchecked!

I have tried the following things already without any success.

  1. Un-install and re-install Office on my machine
  2. Manually install, un-install, re-install the .vsto file for my add-in
  3. Installed 'Remote Tools for Visual Studio 2019'
  4. Verified that the registry location for excel is in the path it is looking for(path in error window)
  5. Verified excel.exe exists in the path mentioned in the error window
  6. Ran using Release-x64 build configuration

While trying all the above options, I have also re-started my machine several times to make sure everything gets removed and installed properly. If anyone has any ideas on what I can do to resolve this, I will highly appreciate it.

getting error excel.application is not defined.

$
0
0

when i try to build project then getting error 

SeverityCodeDescriptionProjectFileLineSuppression State
ErrorBC30002 Type 'Excel.Application' is not defined.

ErrorBC30002Type 'Excel.Workbook' is not defined.

ErrorBC30002Type 'Excel.Worksheet' is not defined.

ErrorBC30002Type 'Excel.Worksheet' is not defined.

-----------------------------------------------------------

Imports System.Security.Cryptography
Imports System
Imports System.IO
Imports System.Net
Imports System.Text
Imports System.Web
Imports System.Data.SqlClient
Imports Excel = Microsoft.Office.Interop.Excel
Imports System.Net.Mail

please help me to solve this.

Thanks.

Why doesn't my code generate the correct footer?

$
0
0

With this code

HeaderFooter _footer = sections[3].Footers[WdHeaderFooterIndex.wdHeaderFooterPrimary];
_footer.PageNumbers.RestartNumberingAtSection = true;
_footer.PageNumbers.StartingNumber = 1;
object CurrentPage = WdFieldType.wdFieldPage;
object TotalPages = WdFieldType.wdFieldSectionPages;
Range footerRange = _footer.Range;
footerRange.Text = "Line1\t";
footerRange.Collapse(WdCollapseDirection.wdCollapseEnd);
footerRange.Fields.Add(footerRange, ref CurrentPage, Nothing, true);
footerRange.InsertAfter(" / ");
footerRange.Collapse(WdCollapseDirection.wdCollapseEnd);
footerRange.Fields.Add(footerRange, ref TotalPages, Nothing, true);
footerRange.InsertParagraph();
footerRange.InsertAfter("Line2");

I cannot post pictures now. So I post the pictures URLs here.

https://i.stack.imgur.com/6uwXQ.png
https://i.stack.imgur.com/BH982.png

Please notify that the current page num “1” and the section pages number “2” appear at the end of the footer.

I have tried the following two macro codes. They all work very well.

Selection.TypeText Text:="line1" & vbTab
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _"PAGE  ", PreserveFormatting:=True
Selection.TypeText Text:="/"
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _"SECTIONPAGES  ", PreserveFormatting:=True
Selection.TypeParagraph
Selection.TypeText Text:="line2"
Selection.TypeText Text:="line1" & vbTab
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldPage, Text:= _"", PreserveFormatting:=True
Selection.TypeText Text:=" / "
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldSectionPages, Text:= _"", PreserveFormatting:=True
Selection.TypeParagraph
Selection.TypeText Text:="line2"


I am searching for a long time on net. But no use. Please help or try to give some ideas how to achieve this.



Visual studio community 2019 license expiry on offline installation

$
0
0

Hi,

I did offline installation of visual studio community on my daughters laptop on which there is no internet connection. After one month it shows license expiry message. How do i activate it without having to connect to internet to login using username. Please advise.

Thanks

Pari22

Outlook Attachment Remove event triggers even if attachment is not really added

$
0
0

Hello,

In my VSTO application I'm capturing outlook mail item AttachmentRemoveevent and doing some required handling. I tried to add a huge file and outlook throws below error which is expected.

What I noticed is that, this case triggers AttachmentRemove event (which is not intended for me). Why is it so? Is there any way to differentiate this from usual attachment removal.  I want my AttachmentRemoveevent handler to run only for  removal of attachments which were successfully added earlier in outlook. How do I achieve this? 

Many thanks in advance.


Outlook 2016 Addin not loading form region BUG only office 365 Outlook 2016

$
0
0

1. 

Mail item opened from Drafts in preview pane don't have mode olFormRegionPreview . item have mode OlFormRegionMode.olFormRegionCompose  its error !!!!!

2

You cannot vote on your own post
0

Open Visual studio 2016-2019, create VSTO Outlook project and add Form region. Set button an form.

run project.

1. Open Outlook

2. Open Mail item from Outlook (Add-in and Form region visible all work ok!)

3 Close Mail item.

4 Open Mail item from file   as file.msg get  BUG ( Add-in working , checked from debugger, Form region is empty can see only NAME of Form region)

Open Mail item from Outlook get  BUG ( Add-in working , checked from debugger, Form region is empty can see only NAME of Form region)

6 Close all Mail item .

Open Mail item from Outlook (Add-in and Form region visible al work ok!)

8 Don't close opened Mail item and  Open Mail item from file   as file.msg get  (Add-in and Form region visible all work ok!)


Question
You cannot vote on your own post
0

Set DsplayConditions -> ShowInspectorRead =true And ShowReadingPane = True

All work but you get error RWC cannot be used ! 

Add to the code FormRegionShowing()

if this is ShowReadingPane set this.OutlookFormRegion.Visible = false;

its all !!!!

VSTO calls fail when document contains invalid URIs

$
0
0

Hey,

we're using VSTO 4.0 on Word documents with customizations.

When a document contains a hyperlink that uses an invalid URI, any call of VSTO functions fail.

Functions like:

Microsoft.VisualStudio.Tools.Applications.ServerDocument.GetCustomizationVersion(myDocXFile);

Microsoft.VisualStudio.Tools.Applications.ServerDocument.RemoveCustomization(myDocXFile);

Error: Invalid URI: The hostname could not be parsed. 

This is reproducable by just adding an uri like this one into a new empty docx: test.email@test..com

Tested with Word 365 (16.0.12527.21096)

Is this a known issue ? 

Thanks,
Oliver

EXCEL VSTO TEMPLATE Not working : Changing Default Security Protocol to TLS 1.2

$
0
0

Hello,

I have an Excel VSTO Template in Excel 2016.
This template communicate with a WCF service with message security using certificate client credential.
I run the template on Windows 10 and the target framework is .NET v4.7.2 for both the template and the service. 
When i disabled TLS 1.0 and TLS 1.1 Security Protocol via IIS Crypto (see bellow the picture), I encounter the following error:
The client and server cannot communicate, because they do not possess a common algorithm.
In fact, when I checked the value in System.Net.ServicePointManager.SecurityProtocol is Ssl3 | Tls.
So the error makes sense but, but I expected to find the value SystemDefault in System.Net.ServicePointManager.SecurityProtocol.

I tried to force the version in the workbook Startup event but it doesn't work.

private void ThisWorkbook_Startup(object sender, System.EventArgs e) {
System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.SystemDefault;
}

What have I missed?

Note that I have a console application that call the same service with the same code and it always works fine after the disable of TLS 1.0 and TLS 1.1 Security Protocol.

I can provide sample projects if needed.

Regards,

Cédric

Problem publishing my vb project

$
0
0
How to I publish my vb project to be used by client which i created the database in firebase Real time database. 

Unable to install an application because an application with the same identity is already installed

$
0
0
Hi All,

I am developing an application in VSTO 2008 using vb. When I attempt to re-install this addin on a PC which already had the addin installed previously, I get the error message:-


"Unable to install this application because an application with the same identity is already installed. To install this application, either modify the manifest version for this application or uninstall the preexisting application."

I have been advised to to use Mage.exe -cc to clean the ClickOnce on the client machine.

Can anyone advise on how to run mage -cc on a client machine that does not have VSTO install?

 

Thanks Bernie


How to create a duplicate of current Word document? (like SaveAs)

$
0
0
Hi,

I want to create a duplicate version of the currently opened document without changing the current doc. SaveAs does the duplication job fine BUT it switches the current doc to the new one.

Any ideas? Thanks!!

PowerPoint Interop selecting Draw > Pen

$
0
0

Dear fellow engineers,

I'm trying to find a way to control pens from the 'Draw' tab in PowerPoint but I had no luck in searching Interop for Office documentation. I did find a way to active and change pen colors in the presentation mode but that's not what I need. 

I want to change those ones: https://i.imgur.com/1nNqcTQ.png

Any idea how to achieve this?

The Outlook API wrongfully shows an outlook folder to have zero sub-folders.

$
0
0

Hello,

I have a long love afair with outlook and recently I built
a simple VSTO 2019 code to move mail items to outlook sub-folders.

This is 365 non-default inbox folder (meaning not under the normal inbox, but rather
the email are under a shared folder which more that one person can access).

We use Outlook 365, version 1908 (build 11929.20708), connected with an Exchange account.

The basic code it to iterate a folder path ("\\DRK\IncomingInbox\Customers\Cust01Box", "\\DRK\IncomingInbox\Customers\Cust02Box" etc),
reach the final sub-folder and move the item to it.

It works, however from time to time the code JAMS because
outlook stops "seeing" the sub-folder under the "\\DRK\IncomingInbox\Customers\" parent folder.

* By "not seeing" I mean that it reports that the parent "IncomingInbox" folder has ZERO sub folders.

* When this happens, the line "Set oFolder = SubFolders.item(FoldersArray(i))" (code below) gives an exception with a err desc of 
"The attempted operation failed.  An object could not be found.".

At any given day this could flap multiple times (seeing and not seeing the sub-folders).

The issue happens with VSTO (VS 2019) and also with VBA.
* In VSTO, switched to  'g_oApp = Globals.ThisAddIn.Application' (instead of 'g_oApp = New Outlook.Application') ,
however it did not help.


Hope I made the issue clear and would love an advice about this matter.


* Just to clarify, A sample of the code to reach a sub-folder
(taken from slipstick.com):

Function GetFolderPath(ByVal FolderPath As String) As Outlook.Folder
    Dim oFolder As Outlook.Folder
    Dim FoldersArray As Variant
    Dim i As Integer

    On Error GoTo GetFolderPath_Error
    If Left(FolderPath, 2) = "\\" Then
        FolderPath = Right(FolderPath, Len(FolderPath) - 2)
    End If
    'Convert folderpath to array
    FoldersArray = Split(FolderPath, "\")
    Set oFolder = Application.Session.Folders.item(FoldersArray(0))
    If Not oFolder Is Nothing Then
        For i = 1 To UBound(FoldersArray, 1)
            Dim SubFolders As Outlook.Folders
            Set SubFolders = oFolder.Folders
            Set oFolder = SubFolders.item(FoldersArray(i))
            If oFolder Is Nothing Then
                Set GetFolderPath = Nothing
            End If
        Next
    End If
    'Return the oFolder
    Set GetFolderPath = oFolder
    Exit Function

GetFolderPath_Error:
    Set GetFolderPath = Nothing
    Exit Function
End Function

Thanks,
OutlookLover

                

How to disable sending Word or Excel document with Outlook application?

$
0
0

Hello everyone,

I have a project that is Word add-in. I control some status in the project. For example;

I try to control DocumentBeforeSave in this way;

 private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            Application.DocumentBeforeSave += Application_DocumentBeforeSave;
        }



 private void Application_DocumentBeforeSave(Word.Document Doc, ref bool SaveAsUI, ref bool Cancel)
        {
            if (SaveAsUI)
            {
                MessageBox.Show("Access denied!");
                Cancel = true;
            }
        }

and this work perfectly. I searched Application events and method for sending e-mail but I could not find.

When user will try to send an e-mail which has an Excel or Word document, I want to disable this process.  

So, I need to control that sending e-mail process in Word, Excel or Outlook application.

Thanks your answers.

0x80029C4A (TYPE_E_CANTLOADLIBRARY)

$
0
0

After installing my application (the installation log looks fine), a particular client (US Military) received the following error when trying to start my application:

 

System.InvalidCastException: Unable to cast COM object of type 'Microsoft.Office.Interop.Word.ApplicationClass' to interface type 'Microsoft.Office.Interop.Word._Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00020970-0000-0000-C000-000000000046}' failed due to the following error: Error loading type library/DLL. (Exception from HRESULT: 0x80029C4A (TYPE_E_CANTLOADLIBRARY)).

 

Based on other responses I have read on this error, it looks like the registry may be corrupted by Anti-virus script blocking software or by multiple instances of Office installed.  Indeed the client is running the Symantec software. Are there other causes I should be aware of?

 

Is there something my code can do to get around this?  I don’t want to have them reinstall Office, as to them it is working fine (i.e. they can start Word and Outlook manually just fine).

 

Viewing all 5157 articles
Browse latest View live


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