interop

How to search for a specific font in a Word document with iterop

♀尐吖头ヾ 提交于 2019-12-02 02:53:57
I use something like this: doc.Content.Find.Font.Name = "Times New Roman"; but when I step through the code the Name property doesn't change. thanks. I'm working with VS2010 and MS Word 2007 and I want to find and replace all "Times New Roman" fonts with "Arial". Here's what happens: Word.Application wordApp = new Word.Application(); Word.Documents docs = wordApp.Documents; doc = docs.Open(fileName, Visible: false); doc.Content.Find.ClearFormatting(); doc.Content.Find.Replacement.ClearFormatting(); // Here the value of Find.Font.Name and Replacement.Font.Name is "" doc.Content.Find.Font.Name =

Get the colour of the screen's current colour filter

流过昼夜 提交于 2019-12-02 02:46:32
The following code SETS the colour filter of the screen to a specific colour. How can I instead GET the colour of the screen? [DllImport("GDI32.dll")] private unsafe static extern bool SetDeviceGammaRamp(IntPtr hdc, void* ramp); private static IntPtr hdc; public unsafe bool SetLCDbrightness(Color c) { short red = c.R; short green = c.G; short blue = c.B; Graphics gg = Graphics.FromHwnd(IntPtr.Zero); hdc = gg.GetHdc(); short* gArray = stackalloc short[3 * 256]; short* idx = gArray; short brightness = 0; for (int j = 0; j < 3; j++) { if (j == 0) brightness = red; if (j == 1) brightness = green;

Detect Outlook installed and load dynamically INterop.Outlook

人走茶凉 提交于 2019-12-02 02:23:54
I have a Windows Forms application in VS2010. It has a reference to Interop.Outlook (2003). Then, I have reinstalled Windows XP and VS2010, but not install Outlook. Now, the project not compiles. I think this, my application will not work if Outlook not installed in machine that my program executes on. I need to know if I detect Outlook installed, and load dynamically Interop.Outlook.dll (for using the Outlook PIA or Embedded Interop types in .NET 4). If the machine has Outlook (2003, 2007, 2010, perhaps need code to detect version and do compatibility of Outlook versions) installed, the

Call a C# method/function from a C++ DLL (which is loaded from C# with “Dllimport”)

北战南征 提交于 2019-12-02 02:23:34
It's a little hard to resume it in a single title, so here my situation. I'm building a C# application that loads a C++ library. I call functions from that C++ DLL. But I'd also like my C++ DLL to call functions from the C# application (that is importing/running it)... Here a piece of code to make it a little more comprehensive : // I'm importing functions from my native code [DllImport(dllFilePath, CallingConvention = CallingConvention.Cdecl)] public static extern int returnIntValue(int value); [DllImport(dllFilePath, CallingConvention = CallingConvention.Cdecl)] public static extern int

help: Call C# winforms dll from VB6 project?

独自空忆成欢 提交于 2019-12-02 02:12:48
问题 I have a VB6 project(windows application) and I have to redevelop a module in the existing VB6 project in C#.net. The module that I develop in C#.net should be a dll and should contain some windows forms. I was able to successfully call a c# console applicaiton dll from my vb6 project but I am facing issues when i try to call a C# class library with winforms from my VB6 project. This is what I have done for my Proof Of Concept - This is a class file in my C#.net class library project.

Casting Range.Value2 of Excel interop to string

我们两清 提交于 2019-12-02 02:02:54
问题 I import some values from Excel sheets in C# application. One column is a text basically but can contain any values. I used the following: Range range = ... // getting this from Excel, works fine string myString = (string)range.Value2; When the cell contains text, this is working. But when it contains, for example, 123, the debugger shows 123.0 for range.Value2 and conversion to string fails with exception. I wonder, how to write the most general conversion for all kinds of cells. At least

Export from DataGrid to Excel with Interop is too slow

只谈情不闲聊 提交于 2019-12-02 01:43:50
I'm about to write a WPF application that takes data from database and displays it in DataGrid. Then with a button an Excel file is created and filled with the data. With large quantities like 20000 lines the filling in Excel takes too long. Does someone have an idea why? Thank you private void copyAlltoClipboard() { Clipboard.Clear(); DataGrid1.SelectAllCells(); DataGrid1.ClipboardCopyMode = DataGridClipboardCopyMode.IncludeHeader; ApplicationCommands.Copy.Execute(null, DataGrid1); } private void Button_Click(object sender, RoutedEventArgs e) { copyAlltoClipboard(); Excel.Application xlexcel;

Changing a window's restore position using SetWindowPlacement doesn't work on every window

断了今生、忘了曾经 提交于 2019-12-02 01:35:03
问题 I'm using the SetWindowPlacement function to (1) maximize and (2) change the restore position of external windows on the desktop. But when I use this command on WinForm windows, it doesn't seem to set the restore location correctly. (The WinForm window I'm testing with is just a VS2008 WinForms application run without modification.) So, for example, if the window is in a restored state located at (0, 0) and I use SetWindowPlacement to maximize it and set its restore position to (100,100),

Is there a way to programmatically add a digital signature to a VBA Macro in a word document?

三世轮回 提交于 2019-12-02 01:12:05
Is there a way to programmatically add a digital signature to a VBA Macro in a word document using C# or VB.Net? There are some similar questions asked already; however, none that I could find answer my question: How to programmatically remove the digital signature from VBA macros in Excel? Digital Signature for Excel Macro Unfortunately, there isn't an automation API for this in the VBA environment. I got it working 100% unattended (so I could use it in automated builds) by P/Invoking Win32 APIs to grab the right window handles and simulate the keyboard shortcuts to those windows, highlight

Changing a window's restore position using SetWindowPlacement doesn't work on every window

心不动则不痛 提交于 2019-12-02 00:58:27
I'm using the SetWindowPlacement function to (1) maximize and (2) change the restore position of external windows on the desktop. But when I use this command on WinForm windows, it doesn't seem to set the restore location correctly. (The WinForm window I'm testing with is just a VS2008 WinForms application run without modification.) So, for example, if the window is in a restored state located at (0, 0) and I use SetWindowPlacement to maximize it and set its restore position to (100,100), then click the window's restore button, it will restore not to (100,100) but to (0,0). It actually seems