ComAutoWrapper 1.1.3.2
There is a newer version of this package available.
See the version list below for details.
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" />
<PackageReference Include="ComAutoWrapper" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=ComAutoWrapper&version=1.1.3.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
🚀 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 | Versions 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.