ComAutoWrapper 1.1.3.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package ComAutoWrapper --version 1.1.3.2
                    
NuGet\Install-Package ComAutoWrapper -Version 1.1.3.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="ComAutoWrapper" Version="1.1.3.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="ComAutoWrapper" Version="1.1.3.2" />
                    
Directory.Packages.props
<PackageReference Include="ComAutoWrapper" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add ComAutoWrapper --version 1.1.3.2
                    
#r "nuget: ComAutoWrapper, 1.1.3.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package ComAutoWrapper@1.1.3.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=ComAutoWrapper&version=1.1.3.2
                    
Install as a Cake Addin
#tool nuget:?package=ComAutoWrapper&version=1.1.3.2
                    
Install as a Cake Tool

🚀 Quick Example (Excel automation)

var excel = Activator.CreateInstance(Type.GetTypeFromProgID("Excel.Application")!);
ComAutoHelper.SetProperty(excel, "Visible", true);

var workbooks = ComAutoHelper.GetProperty<object>(excel, "Workbooks");
ComAutoHelper.CallMethod(workbooks, "Add");

ComAutoHelper.CallMethod(excel, "Quit"); ```

🔍 COM Member Introspection
You can list all callable members of any IDispatch COM object:

```csharp
var (methods, propsGet, propsSet) = ComTypeInspector.ListMembers(comObject);

methods.ForEach(m => Console.WriteLine("Method: " + m));
propsGet.ForEach(p => Console.WriteLine("PropertyGet: " + p));
propsSet.ForEach(p => Console.WriteLine("PropertySet: " + p)); ```


Get the COM type name:

```csharp
string typeName = ComTypeInspector.GetTypeName(comObject);
Console.WriteLine($"COM type: {typeName}"); ```


🧰 Property Access

Set properties
```csharp
ComAutoHelper.SetProperty(app, "DisplayAlerts", false);
ComAutoHelper.SetProperty(sheet, "Name", "Summary");
ComAutoHelper.SetProperty(rng, "Value", new object[,] { ... }); ```

Get properties (typed or untyped)
```csharp
bool visible = ComAutoHelper.GetProperty<bool>(excel, "Visible");
object sheets = ComAutoHelper.GetProperty<object>(workbook, "Sheets"); ```

⚙️ Method Invocation
With return type:
```csharp
int count = ComAutoHelper.CallMethod<int>(workbooks, "Count");
object sheet = ComAutoHelper.CallMethod<object>(sheets, "Item", 1); ```
Or generic/untyped:
```csharp

object result = ComAutoHelper.CallMethod(sheet, "Calculate"); ```

### 🔍 Check if a COM property exists

You can safely check if a property exists on a COM object:

```csharp
bool exists = ComAutoHelper.PropertyExists(excel, "DisplayAlerts");
if (exists)
    Console.WriteLine("Property exists."); ```


✅ TryGetProperty: safely get a COM property
You can try getting a property without catching exceptions:
if (ComAutoHelper.TryGetProperty(excel, "Version", out string? version))
{
    Console.WriteLine($"Excel version: {version}");
}
else
{
    Console.WriteLine("Property not found or failed.");
}

## Full Excel + Word automation demo

This WPF app runs both Excel and Word COM automation examples without any Interop DLLs:

- Writes data into Excel
- Formats Word paragraph
- Inspects COM members via `ComTypeInspector`

Source: [ComAutoWrapperDemo](https://github.com/pmonitor0/ComAutoWrapperDemo)


🙏 Köszönetnyilvánítás
A ChatGPT által nyújtott segítségért, amely hozzájárult a projekt egyes részeinek megvalósításához.

📄 License
MIT

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.4 103 7/16/2025
1.1.3.2 120 7/15/2025
1.1.3.1 96 7/12/2025
1.1.3 86 7/12/2025
1.1.2 131 7/10/2025
1.1.1 137 7/6/2025
1.1.0 135 6/23/2025
1.0.0 134 6/23/2025