View previous topic :: View next topic |
Author |
Message |
simhau
Joined: 06 Feb 2007 Posts: 55
|
Posted: Wed Sep 10, 2008 10:17 am Post subject: DispatchObject.target_ is null even though it shouldnt.... |
|
|
I'm wrapping up some Excel functions, but there is a problem that I really don't know why is happening.
In Excel you can specify several ranges by comma separating them. Range("A1:A2,B1:B2") will then work. Another possibility is by combining them with the Union method. As you see under, both these fails with dwin.
Am I using the library incorrectly, or could this be a bug?
Code: |
import dwin.sys.win32.com.Core;
import dwin.sys.win32.com.Client;
template GetPropObj(char[] N, char[] T)
{
mixin("Excel."~T~" "~N~"() { return new "~
"Excel."~T~"(get!(IDispatch)(\""~N~"\"));}");
}
template GetPropObj(char[] N)
{
mixin GetPropObj!(N, N);
}
template GetPropObjWithArgs(char[] N, char[] T)
{
mixin("Excel."~T~" "~N~"(A ...)(A Args) { return new "~
"Excel."~T~"(get!(IDispatch)(\""~N~"\", Args)); }");
}
template GetPropObjWithArgs(char[] N)
{
mixin GetPropObjWithArgs!(N, N);
}
abstract final class Excel
{
static class Range : DispatchObject
{
this(IDispatch target) { super(target); }
}
static class Worksheet : DispatchObject
{
this(IDispatch target) { super(target); }
mixin GetPropObjWithArgs!("Range");
}
static class Workbooks : DispatchObject
{
this(IDispatch target) { super(target); }
void Add() { call("Add"); }
}
static class Application : DispatchObject
{
this() { super("Excel.Application"); }
mixin GetPropObj!("Workbooks");
mixin GetPropObj!("ActiveSheet", "Worksheet");
mixin GetPropObjWithArgs!("Union", "Range");
}
}
void main()
{
scope xls = new Excel.Application;
xls.Workbooks.Add;
scope s = xls.ActiveSheet;
scope r1 = s.Range("A1:B2");
assert( r1.target !is null ); // OK - regular use
scope r2 = s.Range("A1:B2,B3:C4");
//assert( r2.target !is null ); // Fails
scope r3 = s.Range("B3:C4");
scope r4 = xls.Union(r1, r3);
//assert( r4.target !is null ); // Fails
}
|
|
|
Back to top |
|
|
simhau
Joined: 06 Feb 2007 Posts: 55
|
Posted: Thu Sep 11, 2008 4:21 am Post subject: |
|
|
If I change the Union call to xls.Union(r1.target, r3.target) and adds this(Variant) to Range the call works, but still, the r2 range should have worked too. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|