Windows error 0x80020005, -2147352571

Detailed Error Information

DISP_E_TYPEMISMATCH[1]

MessageType mismatch.
Declared inwinerror.h

HRESULT analysis[2]

FlagsSeverityFailure
Reserved (R)false
OriginMicrosoft
NTSTATUSfalse
Reserved (X)false
FacilityCode2 (0x002)
NameFACILITY_DISPATCH[2][1]
DescriptionThe source of the error code is a COM Dispatch.[2][1]
Error Code5 (0x0005)

Questions

10votes
2answers

excel 2010 Type Conflict NumberFormat

I have a small program which creates Excel files from a database table, with Excel 2013 it works all fine, but i Need it now for Excel 2010 and now I get the following exception when i will add the "Format" to the NumberFormatLocal (range.NumberFormatLocal = format;) The same exception [...] read more
c#
excel
excel-2010
6votes
2answers

how to edit TimescaleStart of MS Project Using C#.net

I have a requirement to modify the ms project file (.mpp) using C#.net. I have done with all the things, the only thing remaining is to modify the TimescaleStart date of MPP file using C#.net. I need to set the user defined date. How can i do that? Following is [...] read more
c#
asp.net-mvc
ms-project
5votes
5answers

Color non-consecutive cells in an Excel sheet

This is what happens: enter image description here [https://i.stack.imgur.com/RLZyM.png] xlValues is set as an Excel.Range object. I have tried the following as well, all giving me the same error: //xlValueRange = xlSheet... .get_Range("A1:A5,A15:A25,A50:A65"); .UsedRange.Range["A1:A5,A15:A25,A50:A65"]; .Range["A1:A5,A15:A25,A50:A65"]; xlApp.ActiveWorkbook.ActiveSheet.Range["A1:A5,A15:A25,A50:A65"]; //I have also tried these alternatives with ".Select()" after the brackets and //", Type.Missing" [...] read more
c#
excel
office-interop
4votes
1answer

DirectoryEntry.Invoke() throws error on "ChangePassword" call

DirectoryEntryObject.Invoke("ChangePassword", new object[] { oldPassword, newPassword } ); throws the following error: > "System.Reflection.TargetInvocationException: Exception has been thrown by the > target of an invocation. > ---> System.Runtime.InteropServices.COMException (0x80020005): Type mismatch. > (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) > --- End of inner exception stack trace --- > at System.DirectoryServices.DirectoryEntry.Invoke(String methodName, [...] read more
c#
active-directory
4votes
2answers

How do I call a VB6 COM object from C# with dynamic when it has a ref parameter?

I have the following legacy VB6 function that I want to call from C#. Public Function CreateMiscRepayment(ByRef objMiscRepayment As MiscRepayment) As Variant ' Code that sets objMiscRepayment here End Function I'm using the following code in C# but getting an exception: dynamic vb6ComObject = Activator.CreateInstance(Type.GetTypeFromProgID(progId)); dynamic miscRepayment = null; dynamic [...] read more
c#
dynamic
vb6
com-interop
late-binding
4votes
1answer

Excel Interop Coloring Cell Using Range

I need to color Excel cells in a fast manner. I found similar method to write to Excel cells which for me is really fast, so I tried applying the same method when coloring the cells. Consider the following code: xlRange = xlWorksheet.Range["A6", "AS" + dtSchedule.Rows.Count]; double[,] colorData = new [...] read more
c#
excel
excel-interop
3votes
1answer

Not able to convert string to DateTime using expression in SSIS

I have 2 variables in SSIS package as CurrFile of string and File_Dt of DateTime datatype. I want to extract DateTime from CurrFile and store it into File_Dt variable. For this I am using expression as below: (DT_DBDATE) SUBSTRING( @[User::CurrFile], 21,14 ) After doing SUBSTRING the value is 20190725001614. Now, [...] read more
sql-server
datetime
ssis
expression
etl
3votes
2answers

Word Automation in C#. Error while using SaveAs

I am getting the following error when trying to Save as Document Object while trying to implement a word automation in C#: > System.Runtime.InteropServices.COMException > > > (0x80020005): Type mismatch. (Exception from HRESULT: 0x80020005 > (DISP_E_TYPEMISMATCH)) > > at Microsoft.Office.Interop.Word.DocumentClass.SaveAs(Object& > > > FileName, Object& FileFormat, Object& LockComments, Object& Password, [...] read more
c#
.net
ms-word
office-interop
3votes
2answers

Is Folder.PropertyAccessor safe to call from managed code?

We recently finished development of a VSTO Outlook add-in. For some configuration data, it uses custom olText properties on a Folder. When our add-in detects that these properties are not available, it uses the UserDefinedProperties property of the Folder to Find/Add our custom properties if they don't exist. if (folder.UserDefinedProperties.Find(propertyName) [...] read more
c#
.net
outlook
vsto
outlook-addin
3votes
1answer

Interop Excel method LinEst failing with DISP_E_TYPEMISMATCH

I am facing a problem while making Excel's LinEST function. My program goes like MyExcel.Application xl = new MyExcel.Application(); MyExcel.WorksheetFunction wsf = xl.WorksheetFunction; List<int> x = new List<int> { 1, 2, 3, 4 }; List<int> y = new List<int> { 11, 12, 45, 42 }; object o = wsf.LinEst(x, y, [...] read more
excel
c#-3.0
excel-interop
3votes
2answers

Excel automation: Range.Find

I want to implement this method in my c# program. But I am having trouble filling in the appropriate parameters in a line like long FirstRow = myWorksheet.Cells.Find( What:="*", After:=Range("IV65536"), LookIn:=xlValues, LookAt:= xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext).Row Here is the documentation for the Range.Find method. Range Find( [In] object What, [In, Optional] [...] read more
c#
excel
2votes
1answer

Guid Object in Function Return in COM Interface

I have a COM Interface which has function signature as mentioned below: Guid GetGuid2() It is implemented in a class: public Guid GetGuid2() { return Guid.NewGuid(); } Then this function needs to be used by Perl. my $dotNetLib = 'MyCOMDLL'; my $server = Win32::OLE->new($dotNetLib) || die "Unable to launch server\n"; [...] read more
c#
.net
perl
com
2votes
0answers

How do I emulate Nothing parameter in VBA inside a Powershell script

I have Excel VBA code that calls Workbook.XmlImport() result=ActiveWorkbook.XmlImport( _ URL:=strXML, _ ImportMap:=Nothing, _ Overwrite:=True, _ Destination:=Range("$A$1") _ ) Note that the second parameter is Nothing -- no import map specified. When I try to move this to PowerShell, I don't know how to specify Nothing. $xl=New-Object -com Excel.Application; $wb=$xl.Workbooks.Add(); [...] read more
excel
powershell
vba
2votes
1answer

How can you ever update a value in CustomProperties collection in Excel VSTO?

I'm working on an Excel Addon using VSTO. I've just run into a weird problem, if I try get a value from the CustomProperties it throws a COM exception and I have no idea why. Has anyone run into this? Here's the code I'm trying to use: CustomProperties properties = [...] read more
c#
excel
vsto
2votes
1answer

set value to Excel cell in C++ throw exception 0x800A03EC

I'm writing an Excel Addin. One of a UDF in the addin is to set value to a selected cell by using Excel Automation in C++. In my code, I have no problem to get range, read value from selected cell, but when I try to set value to cell, [...] read more
c++
excel
automation
cell
2votes
1answer

How to return an array of .NET objects via a COM method

I have a .NET assembly. It happens to be written in C++/CLI. I am exposing a few objects via COM. Everything is working fine, but I cannot for the life of me figure out how to return an array of my own objects from a method. Every time I do, [...] read more
.net
com
c++-cli
com-interop
safearray
2votes
3answers

.NET mshtml: How to pass a BSTR SAFEARRAY?

The class mshtml.HTMLDocumentClass in Microsoft.mshtml.dll assembly has a method: public virtual void write(params object[] psarray); Avoiding the real question for a moment, what code would you use to call write()? Would you use: String html = "<html><body>Hello, world!</body></html>"; mshtml.HTMLDocumentClass doc; ... doc.write(html); or would you use: String html = "<html><body>Hello, [...] read more
.net
com
interop
mshtml
1vote
1answer

Pass Interface Array from C# COM Server to C++ Via IDispatch

I am trying to develop a C# COM server that is accessible to clients only via IDispatch. Some of the methods of my COM objects return an array of interfaces to other COM objects. When I attempt to do this using early binding, such as via the code provided in [...] read more
c#
c++
com
1vote
2answers

Troubles using Powershell and Word SaveAs()

From examples on the net, I have cobbled together this script which I hope will save Word .doc files as plainText. It does not. First, the Word window appears when I have given $word.Visible = $False. Then, a dialog appears asking if I want to open a read-only copy. No [...] read more
.net
powershell
ms-word
office-interop
1vote
0answers

Replacing a unmanaged(MFC) COM server with a .NET COM server, used in unmanaged COM Clients (MFC)

I have a MFC COM server (ActiveX) and a MFC COM client. The server is build up from the following IDL: library SomeLib { importlib(STDOLE_TLB); [ uuid(some-guid), dispinterface ISomeIntf { methods: [id(1)] HRESULT Foo( ); } [ uuid(some-guid), coclass SomeClass { [default] dispinterface ISomeIntf; }; } The client is using [...] read more
c++
.net
mfc
com
1vote
0answers

CS0433 Type exists in two assemblies

Short version At runtime, I'm getting a type mismatch error from Microsoft.Office.Interop.Excel, because Visual Studio thinks this Interop .dll is also part of my assembly and it can't decide which of the two equally named types it's perceiving (XlYesNoGuess) to use as my second parameter of Range.RemoveDuplicates(object, XlYesNoGuess). Please help [...] read more
c#
excel-interop
1vote
1answer

Reading internet headers set in an Outlook email by Azure Information Protection Unified Labeling Client

I am using Azure Information Protection Unified Labeling client to label emails. We are still using PGP in our environment and emails classified strictly confidential must be PGP encrypted. When the email is sent, I try to find out, how the email is classified and trigger PGP encryption, when the [...] read more
c#
vsto
outlook-addin
azure-information-protection
1vote
1answer

How to use optional parameters with QAxFactory based API

I'm currently implementing an QAxFactory based COM-Api and want to give some of the functions default parameters. However, this seems not to work since when I call said functions without these default parameters I receive an error (HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)). I found some advice about linking signals and slots within [...] read more
c++
qt
1vote
0answers

Type mismatch on excel data from powershell

Good day everyone. I am a starting programmer in powershell and am trying to make a program input help desk calls into an excel sheet to import into the help desk ticketing system. My script: $excel_file_path = 'G:\IT\Helpdesk\Daily Calls.xlsx' ## Instantiate the COM object $Excel = New-Object -ComObject Excel.Application $ExcelWorkBook [...] read more
excel
powershell
type-mismatch
hresult
1vote
1answer

How to pass a C#.net Dictionary to VBA

I am trying to pass a Dictionary from c# to vba but this error occurs System.Runtime.InteropServices.COMException: 'Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))' I also tried converting my list of string into vb collection but the same error occurs. here are my codes private void btn_macrorunner_Click(object sender, EventArgs e) { [...] read more
c#
vba
excel
1vote
0answers

Calling ActiveX control function with ref parameter from VB.NET

I have a VB.NET winforms app which uses an ActiveX control (ocx). Via interop, I have a reference to an object defined in the ocx and call various functions on it. This works ok for the most part. I had some issues with one function call causing a memory leak [...] read more
c#
vb.net
dynamic
com-interop
1vote
1answer

The member does not exist? Powershell script

I have been reading some questions and can find information on creating scripts but none seemingly using the object type "Computer". Apologies if this is more suited to superuser. But this is still at the script level and as such I thought it would be best placed here. Here is [...] read more
powershell
adsi
1vote
2answers

Setting an array using Ruby and Win32OLE

I'm trying to set an array property in a COM object using Ruby v1.93. Marshalling an array from COM into a Ruby array just works, but not in the other direction. How do I marshall a Ruby array into COM? The property is contained in a .NET assembly: namespace LibForRuby [...] read more
ruby
win32ole
1vote
0answers

Office Interop Word Mail Merge throws DISP_E_TYPEMISMATCH exception

My issue involves a word file which has a macro embedded from another company which we have to remove and then set a new data source path (xlsx spreadsheet). The macro must be removed because it already sets the data source which is not available anymore when we get the [...] read more
c#
excel
ms-office
1vote
0answers

C# Calling COM API results in Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

I'm upgrading an old vba app to a C# app. The app automates Solid Edge (cad 3D program from Siemens). I'm having trouble calling a specific method of the Solid Edge API. The method in question has a bunch of ref and out parameters, I only care about one, representing [...] read more
c#
.net
1vote
1answer

Unable to write to or read from Worksheet.CustomProperties in a console application

In my console application, I am trying to write something to and read it back from the CustomProperties of an Excel worksheet. I have a reference to the Microsoft.Office.Interop.Excel v14 assembly. At the line that calls the firstWorksheet.CustomProperties.Add method, I get an exception with the HRESULT 0x800A03EC. Below is the [...] read more
c#
excel
com
ms-office
office-interop
1vote
1answer

Search a Lotus Notes database from PowerShell

I am trying to search a Lotus Notes database from PowerShell and getting a "Type Mismatch. (Exception from HResult: 0x80020005 (DISP_E_TYPEMISMATCH)" At line 1: char:1. Set-up code: $notesSession = New-Object -ComObject Lotus.NotesSession $notesSession.Initialize() $notesDb = $notesSession.GetDatabase(..., ...) I get the errors when trying... $results = $notesDb.Search("text", $null, 0) $results = [...] read more
powershell
lotus-notes
1vote
0answers

Type mismatch error-csharp converting word to PDF

I'm trying to convert a Doc to PDF. There is an error after opening PDF Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application(); object _MissingValue = System.Reflection.Missing.Value; public void WordtoPdf_Input() //word to PDf conversion { string filename_doc=System.IO.Path.GetFileName(LblFleip.Text); string wordFileName = LblFleip.Text; string pdfFileName=string.Empty; appWord.Visible = false; appWord.ScreenUpdating = false; // Cast as Object [...] read more
c#
.net
visual-studio-2010
ms-word
office-interop
1vote
1answer

Powershell - .GetType().InvokeMember() throws Type mismatch Error

I am trying to extract certain values from an .msi file with Powershell to help automate an installation. I came across a method involving calling InvokeMember() such as example 1 and example 2. I tried this myself with the following code - $windowsInstaller = New-Object -ComObject WindowsInstaller.Installer $mSIPath = $prereqComponent.getAttribute("msiFilename") [...] read more
sql
powershell
windows-installer
1vote
0answers

C++ managed code calling unmanaged code with handles

After an afternoon of searching this problem has got me stumped! I'm writing a managed C++ application which needs to call some unmanaged code. This is the function I need to call: public: void Connect( [out] LONG* pCookieID, [out] LONG* pNumberOfStreams, [out] VARIANT* pMediaType ); And the documentation has this [...] read more
c++
.net
unmanaged
1vote
1answer

PowerPoint 2007 SP2, ExportAsFixedFormat in PowerShell?

Yesterday I was trying to batch convert a group of PPTs into PDFs for a friend, and I decided to have a look at PowerShell, since it's been sitting on my HD for a while. Here's the code I've come up with. $p = new-object -comobject powerpoint.application # I actually [...] read more
pdf
com
powershell
powerpoint
office-2007
1vote
2answers

How to create Excel 2003 UDF with a C# Excel add-in using VSTO 2005 SE

I saw an article on creating Excel UDFs in VSTO managed code, using VBA: http://blogs.msdn.com/pstubbs/archive/2004/12/31/344964.aspx. However I want to get this working in a C# Excel add-in using VSTO 2005 SE, can any one help? I tried the technique Romain pointed out but when trying to load Excel I get [...] read more
c#
excel
vsto
add-in
user-defined-functions
1vote
1answer

using excel range find return Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

I'm working on Excel add-on I need to search Values on cell (selected by user) in Column (Selected by user) and write result in cell (selected by user) Ex: if cell A2 exist in column B in rows 5, 10, and 15 result in C2 must be 5,10,15 I Face [...] read more
vb.net
excel
visual-studio-2013
1vote
0answers

How to pass a struct parameter using TCOM in Tcl

I've inherited a piece of custom test equipment with a control library built in a COM object, and I'm trying to connect it to our Tcl test script library. I can connect to the DLL using TCOM, and do some simple control operations with single int parameters. However, certain features [...] read more
com
tcl
1vote
1answer

How to send in a callback object from .net to custom Word macro

I've got some VB.net code and a custom Microsoft Word VBA macro. I'm trying to pass the VB.net instance into the macro so that i can run a function on that object from the macro. I can't seem to pass in the object from the VB.net code to the Macro. [...] read more
.net
vb.net
vba
ms-word
1vote
1answer

C# SyncObject with Outlook Interop

I am hoping someone can help me. Let me first state that I am a very amateur programmer. I have an IMAP email account within outlook. I want to take a single email folder within that account and ensure that all the messages in that folder within outlook are in [...] read more
c#
interop
outlook
1vote
3answers

Pivot Cache Type Mismatch error VB.NET Excel

Please see bottom edit for where I am currently at, thank you. I have created a pivot table that works fine when the pivot cache is defined as: Dim ptCache As Excel.PivotCache = mainHighway.PivotCaches.Add(SourceType:=Excel.XlPivotTableSourceType.xlDatabase, SourceData:=mainHighwayData.Range("a1:v7500")) My problem is that the number of rows changes from day to day, so I [...] read more
.net
vb.net
excel
pivot-table
1vote
1answer

How do I call a COM-function with a _variant_t parameter (type "long")?

I want to port a certain function call to C#. The two lines are as follows: m_pBrowserApp->get_Document(&pVoid); m_pLayoutAnalyzer->Analyze4(pVoid, _variant_t(5L)); m_pBrowserApp is the ActiveX browser object and pVoid is its document property. I can get that by calling WebBrowserBase.ActiveXInstance.Document. However, I have no idea how to create a _variant_t(5L) in C#. [...] read more
c#
com
interop
com-interop
1vote
2answers

Refresh Sharepoint-linked Table in Access?

I have an access table in 2007 that is linked to a sharepoint list. When a new record is added to the sharepoint list, the change does not get automatically reflected in the access table. If you right click on the linked table, there is an option to "refresh list" [...] read more
sharepoint
ms-access
powershell
ms-access-2007
1vote
1answer

Handling SharePoint UpdateListItems XML Response

I'm inserting some items into a SharePoint 2007 list using the Lists web service. I'm trying to write some code to handle any errors reported in the response, but navigating the XML is not working as expected. I'm attempting to get a collection of Result elements, then check each Result's [...] read more
c#
xml
xpath
sharepoint-2007
1vote
0answers

Call to EnvDTE.TextSelection.FindPattern from PowerShell fails with type mismatch

I'm building a custom scaffolder to use with MvcScaffolding. Trying to automate adding code to the beginning of a method, I came up with the following code: $codeElement = Get-ProjectType "MyType" foreach ($member in $codeElement.Members) { if ($member.Name -eq "CreateMappings") { $editPoint = $member.StartPoint.CreateEditPoint() # here's where it's crashing $editPoint.FindPattern("\{") [...] read more
powershell
com
envdte
asp.net-mvc-scaffolding
1vote
1answer

Marshalling C# types to call a C++ IDispatch interface results in a type mismatch

I'm trying to call a c++ IDispatch interface with the following method definition: ATL HRESULT TestFunc(long Command, [in, out] long* pData, [in, out] BSTR* pString, [out, retval] long* pRC); // ... Type t = Type.GetTypeFromProgID( "IMyTestInterfce" ); Object so = Activator.CreateInstance(t); Object[] args = new Object[3]; args[0] = -8017; args[1] [...] read more
c#
c++
com
1vote
1answer

Calling Vix API from PowerShell

Long time stackoverflow reader, first time poster. Forgive me if I'm not asking a question correctly. I'm trying to use the VixCOM API with PowerShell. I don't have much experience with either. I am aware of VMWareTasks: C# VixCOM wrapper library & tools . I've used it with success, but [...] read more
powershell
vmware
vix
1vote
0answers

Sharepoint 2010 : web.ProcessBatchData is throwing the error

i am facing an issue while trying to migrate the data from one list to other, the list is having custom columns which are of type "Single line of Text","Multiple line of Text","Person or Group","Datetime","Integer". i am getting the below error after execution of the statement "Web.ProcessBatchData" ..... The operation [...] read more
sharepoint
0votes
1answer

Powershell Export-Clixml object manipulation

I want to be able to save an object to file, and then have another script pick up that object again and be able to use it. I run Export-Clixml -InputObject $object -Encoding UTF8 -Path $file to save the object to file, but if I run $object = Import-Clixml $file [...] read more
powershell
0votes
0answers

Not able to convert datetime to string in SSIS Expression

I am using ssis expression to add a day to a project parameter. Project parameter and out put variable both are string datatype. Please see below code SUBSTRING((DT_STR,30, 1252) DATEADD("dd",1,(DT_DBDATE)@[$Project::Proj_End_Date]), 1, 10) The above is working fine when date passed as "2017-03-10" but it is failing when the Proj_End_Date value [...] read more
sql-server
string
date
ssis
expression
0votes
2answers

How to use Document.PrintOut method from Microsoft.Office.Tools.Word to print the first page of a document

The documentation is here: https://docs.microsoft.com/en-us/dotnet/api/microsoft.office.tools.word.document.printout?view=vsto-2017 This will print the whole document: Word.Application ap = new Word.Application(); Word.Document document = ap.Documents.Open(@"C:\temp\file.doc"); document.PrintOut(); I thought I were on to something with this as it compiled but it didn't work: Word.Application ap = new Word.Application(); Word.Document document = ap.Documents.Open(@"C:\temp\file.doc"); Word.WdPrintOutRange printRange = new [...] read more
c#
0votes
0answers

Why I have problems when calling OCX C++ code using C#

I have a problem when calling an OCX method using C#. OCX component is developed in C++. I get this error: "System.Runtime.InteropServices.COMException (0x80020005): Los tipos no coinciden. (Excepción de HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))\r\n en System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)\r\n en MFCActiveXControl1Lib._DMFCActiveXControl1.LeoCadena(IntPtr nombreFichero, IntPtr contenidoFichero, Int32 LongitudFichero)\r\n [...] read more
c#
c++
com
interop
ocx
0votes
1answer

limitation of rows number for making Pivot Table in c#

I am creating a Pivot Table programmatically in c#. the code fines when the Source data ( which is a sheet in excel). It works fine till the source sheets contains 65536 rows, more than that, an error appears which says > Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) This [...] read more
c#
excel
pivot-table
0votes
1answer

Unable to select Values for X-axis of a Powerpoint line chart

I have developed a powerpoint plugin to insert a line chart with markers This chart number of hours worked on each day for a given week. Program first adds a chart to a slide using AddChart2. Then adds data in the worksheet attached to the chart : Weekly data for [...] read more
c#
powerpoint
vsto
office-interop
excel-interop
0votes
1answer

ASP.NET: Modify and download docx file

I have a docx file which I would like to modify according to web user input. So, after the user submits the form on the web page, I need to modify the original docx file, and then download it to the user. I try to store the original file as [...] read more
c#
asp.net
docx
word-interop
0votes
1answer

Do I need to define default values in Excel Range.Find, or can I skip some parameters?

I need to do a case insensitive search in an Excel document using Range.Find. I'm currently using the following command as an attempt do a case insensitive search for any email address returned by https://haveibeenpwned.com $Found = $WorkSheet.Cells.Find($SearchText, $null, "xlValues", "xlWhole", "xlByRows", 1, $false) #What, After, Lookin, LookAt, SearchOrder, MatchCase [...] read more
excel
powershell
0votes
0answers

IIS Application Pool configured to specific User MSA Account Through Powershell

I am not sure why it's happening but I am stuck in a point when I am trying to Configure my AppPool with a Specific Account i.e. MSA or Service Account. I am running below script in PowerShell to do the configuration: Import-Module WebAdministration Set-ItemProperty IIS:\AppPools\AppPool -name processModel -value @{userName="$user_name";password="$password";identitytype=3} [...] read more
powershell
windows-server-2016
powershell-5.0
iis-10
0votes
0answers

System.Runtime.InteropServices.COMException Type mismatch. Error when trying to create an xls file with data

I followed the guide in this link: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/interop/how-to-access-office-onterop-objects Here is my code: string fname = "Inventory Report.xls"; var excelApp = new Excel.Application(); // Make the object visible. excelApp.Visible = true; // Create a new, empty workbook and add it to the collection returned // by property Workbooks. The new workbook [...] read more
c#
interop
0votes
1answer

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in Microsoft.VisualBasic.dll

I'm trying to call a method from an old VB DLL and getting this error: > An unhandled exception of type 'System.Runtime.InteropServices.COMException' > occurred in Microsoft.VisualBasic.dll Additional information: Type mismatch. > (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) This is a VB project using VS Community 2015. It successfully loads the dll [...] read more
vb.net
dll
0votes
1answer

Foreground browser window

I'm trying to write a script that can do a few basic keyboard and mouse events, and then 'open' the current Chrome window, and continue from there. The only problem is that I cannot find a way to bring the Chrome window to the foreground. The code works with simple [...] read more
powershell
0votes
0answers

Type.InvokeMember Throwing "COMException: Type mismatch" inside Extension method

I'm working with Adobe Acrobat SDK, and I am trying to clean up the COM calls by wrapping the InvokeMember call in an Extension method to make the code a bit more readable. The extension method I am trying to write is as follows: using System; using System.Reflection; public static [...] read more
c#
com
extension-methods
acrobat-sdk
0votes
0answers

Opening Large Set of Word Documents With Powershell - Automation

I am in the process of assigning a footer to hundreds of word documents with their current filepath. Here is my code, which does the job: I plan to have $Word.Visible set to false, but it isn't for now for debugging purposes. This gets all the word docs in a [...] read more
powershell
automation
ms-word
0votes
1answer

Programmatically Open Word Document Located in the Resource1.resx in C#

Im using WinForms and i try to open MS Word document (with some help info) on button click from my form My code : using Microsoft.Office.Interop.Word; Microsoft.Office.Interop.Word.Application ap = new Microsoft.Office.Interop.Word.Application(); Document document = ap.Documents.Open(Resource1.sign_full); My .docx file is sign_full.docx. I added it to my project Resource1.resx file. Then If [...] read more
c#
ms-word
0votes
1answer

MS Word InsertBreak throws exception

I'm getting error "Type mismatch" when trying to InsertBreak via Range using parameters (for instance, wdPageBreak or wdLineBreak). But it's ok, to InsertBreak parameterless. Am I the only one getting such a behaviour, or is it another Word API bug? //MS Word VBA Reference Set myRange = ActiveDocument.Paragraphs(2).Range With myRange [...] read more
c++
vba
ms-word
ms-office
0votes
0answers

LeanFT: Unable to invoke methods with non-primitive parameter: No object is registered with cookie: [object Object]

I'm trying to invoke a method on a NativeObject, e.g.: nativeObject.invokeMethod("scrollRectToVisible", new DynamicObjectProxy(new Rectangle())); I came up with the idea to pass a DynamicObjectProxy as a method parameter as the "invokeMethod"-method of a NativeObject always returns a DynamicObjectProxy for non-primitive return types. However, the following exception arrises: com.hp.lft.sdk.GeneralLeanFtException: no object [...] read more
java
testing
hp-uft
leanft
0votes
1answer

Range.Find - Type mismatch. when searching for long strings

In C# VSTO for excel, When I use the Find method on very long strings I get: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) Any Ideas? read more
vsto
excel-interop
0votes
1answer

Using Visio shape.getFormulas

I would like to extract some Information out of Visio shapes using vb.net. Therefore I think shape.getFormulas is the best opportunity. By executing this line I get the error: > Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) (I read in other posts that there might be a problem if SID_SRCStream [...] read more
vb.net
binding
visio
0votes
1answer

Changing Local Admin Password Using Encrypted Password.txt

I'm trying to update a local admin account password. I don't want to pass the password in plain text, so i found a workflow (https://www.pdq.com/blog/secure-password-with-powershell-encrypting-credentials-part-2/) that will allow me to encrypt PW's. #Change password for TestAccount $User = 'TestAccount' $PasswordFile = "$PsScriptRoot\Password.txt" $KeyFile = "$PsScriptRoot\AES.key" $key = Get-Content $KeyFile $MyCredential [...] read more
windows
powershell
encryption
powershell-4.0
0votes
0answers

How to assign a value to BSTR in C#

As part of a legacy automation, we try to assign "c:\temp" to a COM object's property. var host = engine.Session.Hosts.Item[HostName]; host.TemporaryDirectory = TemporaryDirectoryPath; During the run, we saw a COMException - "Type mismatch...0x80020005..." It seems that the property is in typeof BSTR and have a default value "50". Can you [...] read more
c#
.net
automation
comexception
bstr
0votes
1answer

How can vb.NET app pass Object array to COM OPC server expecting Variant array

I am using Visual Studio 2012 .NET 4.0 I have been tasked with moving an application from one system to another. Due to some hardcoded sever refences in the original I have been forced to revise some of the source which is probably vb6 (zero comments in the source). Visual [...] read more
vb.net
0votes
2answers

type mismatch when running Access.Application.DoCmd through Powershell

I'm having an issue with my code. I am hoping to use PowerShell to open an Access file, then export a table to an Excel file. so far, this is my code. $MsAccess = New-object -com Access.Application $MsAccess.OpenCurrentDatabase('<Filepath>',$false) $MsAccess.Application.DoCmd.OpenTable("<TableName>") $MsAccess.Application.DoCmd.OutputTo('acOutputTable, "<TableName>" , acFormatXLS , "OutputName.xls", true') $MsAccess.CloseCurrentDatabase() $MsAccess.Quit() It will [...] read more
excel
vba
powershell
ms-access
com
0votes
1answer

Add arguments (variables) when calling a -ComClient from Powershell

I am quite new dealing with COM libraries and so on and I have step into a problem that I don't know how to solve. I have a code in Python using a library that I would like to transform into Powershell. So I have a COM library I want [...] read more
python
powershell
com
0votes
1answer

Excel Interop Error On Workbook Open

I got an error when trying to open excel workbook: var workbook = Workbooks.Open(filePath) After that every time I've got: > Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH) What is interesting, when im using Thread.Sleep(2000) before "Open" function everything is working correctly: Thread.Sleep(2000); var workbook = Workbooks.Open(filePath) Code is running on main [...] read more
c#
excel
office-interop
0votes
1answer

VB.net program falling foul of InteropServices.COMException Bug

I have a VB.net program that I wrote and have used hundreds of times. Whilst using Windows 7 I "upgraded" to Office 2010 and IIRC had to make a few small changes to get it to work. I have now (and again I put it in quotes as I fail [...] read more
vb.net
0votes
1answer

Can't pass C# int array to VBA Excel macro

I'm trying to call a macro of my Excel worksheet (2003) from my C# application with the C# Interop. It worked fine before with Integer parameters. But now I need to pass an Array of Integers and I keep getting a type mismatch exception. COMException: Type mismatch. (Exception from HRESULT: [...] read more
c#
vba
excel
macros
0votes
0answers

Error in opening & repairing word through Powershell script

I am using the following powershell script code to open and repair corrupted documents. $word = New-Object -ComObject word.application $word.Visible = $true $word.documents.Open($Doc, $false, $false, $false, $false, $false, $false, $false, $false, $false, $false, $true, $true) #Log opening the file Log-Write -LogPath "$Logpathfilename" -LineValue "$DocLeaf - Opening File" RepairProgress "Repair Progress [...] read more
.net
windows
powershell
ms-word
0votes
0answers

SSIS Package validation errors due to expected empty variable

I have a number of SSIS packages which I have deployed to SQL Server 2014. The packages take a file parameter which I place into a variable. From that rawFile variable a number of variables are derived. The packages are running fine in my development environment and are providing me [...] read more
sql
ssis
sql-server-2014
ssis-2012
0votes
1answer

Programmatically convert Power Point presentation to PDF in .net

After searching a bit I still haven't got what I need. I'm trying to convert various files to PDF using VB.Net and referencing various MS Office components like Word/Excel/PowerPoint as either COM objects or by using the PIA (Office Interop Assemblies). In the end I want to use the COM [...] read more
.net
vb.net
pdf
ms-office
powerpoint
0votes
1answer

Tcl - How to sort excel using tcom

Excel sorting requires specifying values in the format: Columns("A:C").Sort key1:=Range("C2"), order1:=xlAscending, header:=xlYes How Do I send it via tcom? I have tried the following unsuccessfully (Users) 14 % set sort [$worksheet Sort] ::tcom::handle0x0201DD00 (Users) 15 % $sort Header xlYes 0x80020005 {Type mismatch.} (Users) 16 % $sort Header 1 (Users) 18 [...] read more
tcl
0votes
2answers

How can I create a new Powerpoint presentation with Powershell

I am trying to create a new Powerpoint presentation with Powershell from scratch but am having trouble with the object model. Based on some code from the ScriptingGuy I came up with: Add-type -AssemblyName office $Application = New-Object -ComObject powerpoint.application $application.visible = [Microsoft.Office.Core.MsoTriState]::msoTrue $slideType = "microsoft.office.interop.powerpoint.ppSlideLayout" -as [type] $blanklayout = [...] read more
powershell
com
powerpoint
0votes
3answers

VB.NET excel deleting multiple columns at the same time

I am trying to delete more than one column in my excel sheet. For Each lvi In ListView1.Items If lvi.Checked = True Then arrayLetters = lvi.SubItems(1).Text & ":" & lvi.SubItems(1).Text & "," & arrayLetters End If Next arrayLetters = arrayLetters.Substring(0, arrayLetters.Length - 1) Dim rg As Excel.Range = xlSheet.Columns(arrayLetters) rg.Select() [...] read more
vb.net
visual-studio-2010
excel
0votes
2answers

PowerPoint ExportAsFixedFormat in Powershell

I try to use the ExportAsFixedFormat in PowerPoint 2007 from a PowerShell 2.0 script. Only the first two arguments are required, but that won't work. I always get: > Exception calling "ExportAsFixedFormat" with "2" argument(s): "Type mismatch. > ( Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))" I've read that all arguments have [...] read more
pdf
powershell
export
powerpoint
0votes
2answers

TFS 2013 upgrade (error TF400534)

We are trying to upgrade our TFS2012 to TFS 2013, however we receive the error-message: Error : TF400534 : Package (updatetfs) caching failed with the following status : 0x80070005 We have administrative rights, enough disk space and have tried both with web-installer and ISO-file. We believe that we meet all [...] read more
tfs
0votes
1answer

Import Local Group from remote server via Powershell

I am working on the easiest way to copy security settings from one server to another, using Powershell, and I'm curious if it's possible to import and entire group, including it's Description and Members properties? Below is the script I currently have. It appears that I can access the local [...] read more
powershell
0votes
1answer

Error While opening PDFand Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))

After i convert code from word to PDf if i input the same word document to convet to PDf the PDF File is damaged. Can you tel me whether this error is because of inputting same word PDf many times or other error. Microsoft.Office.Interop.Word.Application appWord = new Microsoft.Office.Interop.Word.Application(); object _MissingValue [...] read more
c#
.net
visual-studio
ms-word
0votes
0answers

UPNP with C# code

I am trying to use UPnP(windows sys upnp.dll) with C# but I am having some troubles to figure out how to call UPnPService.InvokeAction. When I call the code below piece of code: string[] inarr = new[] { "", ""}; object outarr = new object[0]; object rvalue = myservice.InvokeAction("GetCompatibleUIs", inarr, ref [...] read more
c#
upnp
0votes
1answer

Type mismatch error in soapmapper

What could be causing the error > Soapmapper: converting data for soapmapper failed inside the typemapper > HRESULT=0x80020005: type mismatch when running the code below? 's is a valid XML xml_doc.LoadXML s Dim Nds As MSXML2.IXMLDOMNodeList Set Nds = xml_doc.ChildNodes Dim module As clsws_ProfileManagement Set module = New clsws_ProfileManagement Set [...] read more
vba
soap
0votes
0answers

sql server 2012 DTSPackage Config File Exception

I have a dtspackage which is executed through the C# coding.Earlier we have used sql server 2008 r2, Now we have moved to sql server 2012. The package was working fine with sql server 2008 while executing through C#code.But now while loading the Config file it throwing the exception like [...] read more
ssis
sql-server-2012
0votes
1answer

Inserting multiple rows into an Excel Sheet with Vb.Net Com Add-In

After determining a row index for an Excel Worksheet, InsertRow, I would like to insert 16 rows after it using VB.net. I am building a COM add-in if that changes anything. In VBA I would do this via: ... Dim InsertRow as String ... Dim ContractForm As Worksheet Set ContractForm [...] read more
vb.net
excel-2010
excel-addins
0votes
1answer

Powershell 3: Convert Word to PDF

I'm fairly new to Powershell and found the following script on the web: (I've modified it for my project) # Acquire a list of DOC files in a folder $Word = New-Object -ComObject word.application $formats = "Microsoft.Office.Interop.Word.WdSaveFormat" -as [type] $Word.visible = $false $fileTypes = "*.docx","*doc" $complyDocPath = "i:\2014\COMPLY\DOC\" $complyPDFPath = [...] read more
powershell
pdf-generation
powershell-3.0
word-2010
0votes
0answers

range.copy method throwing unexpected error

I have the following code to copy data between 2 different excel files xlRangeSource = xlsheetSource.Range("B2:K" & IntAmountOfRows) xlRangeTarget = xlsheetTarget.Range("A" & intStartOfEmptyRow) xlRangeSource.Copy(Destination:=xlWbTarget.Worksheets(xlsheetTarget).range(xlRangeTarget)) IntAmountOfRows and intStartOfEmptyRow are both integers When executing my code, I get the following error: Type mismatch. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH)) However, I am using [...] read more
vb.net
excel
0votes
1answer

Error when function "OpenDataSource" is called

I want to create a MS Word merge document. I have already created a template document. When my application is started, it creates an ODBC, called "Hrms2008". I am new to this kind of stuff, that's why I don't know what causes the error. word.Application wrdApp; word.Document wrdDoc; object oMissing [...] read more
c#
sql-server-2008
ms-word
dsn
mailmerge
0votes
1answer

c# com object cant get ref object values

We are trying to get values returned from a COM object, the function is: bool AxSB100BPC.GetEnrollData(int dwMachineNumber, int dwEnrollNumber, int dwEMachineNumber, int dwBackupNumber, ref int dwMachinePrivilege, ref object dwEnrollData, ref int dwPassWord We are calling this function as: vRet = axSB100BPC1.GetEnrollData(mMachineNumber, vEnrollNumber, vEMachineNumber, vFingerNumber, ref vPrivilege, ref oglngEnrollData, ref glngEnrollPData); [...] read more
c#
object
com
marshalling
0votes
0answers

Changes to MS WORD through C#

I am trying to save the document which i have opened through C#, I have kept the TrackRevision property of document interface also. Now I want to get the name of the person who has modified the document.In MS word I can find the name of the user from the [...] read more
c#
asp.net-mvc
0votes
1answer

Powershell code works in editor but not in Powershell cmd it self?

When i run this code in the editor it works perfectly: (not a single error) $vm = 0 $vpc=new-object –com VirtualPC.Application –Strict foreach ($vm in $vpc.VirtualMachines){} $broken = Get-WmiObject Win32_PnPEntity | where {$_.ConfigManagerErrorCode -ne 0} $usbDevice = $vpc.USBDeviceCollection | ? {$_.DeviceString -eq $usb} | select -first 1 $vm.AttachUSBDevice($usbDevice) when i [...] read more
powershell
cmd
xp-mode
-1votes
1answer

Why am I getting a Type Mismatch when assigning a Worksheet to a Worksheet var?

I am trying to incorporate Aspose Cells for .NET into this class that is using Excel Interop (rather than rewrite the whole thing to use Aspose Cells, which I am just now trying out, I want to at least start with a hybrid approach). The problem is that I get [...] read more
worksheet
type-mismatch
aspose-cells
-1votes
1answer

How to debug a powershell exception calling "InvokeMember" with "5" argument(s): Type mismatch

I'm trying to implement this code example from the Scripting Guy: http://blogs.technet.com/b/heyscriptingguy/archive/2010/04/06/hey-scripting-guy-how-can-i-add-custom-properties-to-a-microsoft-word-document.aspx Code: $path = "C:\fso\Test.docx" $application = New-Object -ComObject word.application $application.Visible = $false $document = $application.documents.open($path) $binding = "System.Reflection.BindingFlags" -as [type] $customProperties = $document.CustomDocumentProperties $typeCustomProperties = $customProperties.GetType() $CustomProperty = "Client" $Value = "My_WayCool_Client" [array]$arrayArgs = $CustomProperty,$false, 4, $Value Try [...] read more
powershell
-1votes
2answers

Type mismatch convert a .doc/docx into a PDF?

In a web application i have to implement a method to convert a doc/docx to a PDF. This is how i am doing it: FileInfo FILE = new FileInfo(path + filename); object missing = System.Reflection.Missing.Value; object readOnly = false; object objfilename = (object)FILE; //Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); try { [...] read more
c#
asp.net
pdf
ms-word
-2votes
1answer

interop error HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH) on server

I am having a problem with my app when trying to run on the server. In my place it works fine but when passed to the server it fails to try to create the pivotcache. Excel has permissions on the server with the user IIS, on my computer I have [...] read more
c#
office365
pivot-table
office-interop
-2votes
1answer

Office Interop Exception running Interop v15 on Windows XP

I am running a .exe that i pass an argument to, using Office.Interop v15. It works fine on the dev machine which is windows 7 with Office 2013. When i move to a VM that is running Windows XP and Office 2010, i get a run time error stating > [...] read more
c#
.net
vb.net
winforms

Comments

Leave a comment

(plain text only)

Sources

  1. winerror.h from Windows SDK 10.0.14393.0
  2. https://msdn.microsoft.com/en-us/library/cc231198.aspx

User contributions licensed under CC BY-SA 3.0