Hi,
This is a very nice trick to call a stored procedure with parameters from excel.
If you type for example
exec model.GetPrices (?,?,?,?)
or
CALL model.GetPrices (?,?,?,?)
you will get this message
"Parameters are not allowed in queries that can't be displayed graphically"
while instead if you put the second Call within {} like that
{CALL model.GetPrices (?,?,?,?)}
it will work!!!
Showing posts with label computing. Show all posts
Showing posts with label computing. Show all posts
Wednesday, October 5, 2011
Monday, November 29, 2010
How to get the scripting dictionary enumerator to use in the for each loop in visual basic
A common practice is writing VB 6.0 or VBA code to wrap the Collection object in order to create strongly type Collections.
An alternative to the collection object is the scripting.Dictionary object which you can find adding a reference to the Microsoft Scripting Runtime.
The Dictionary Object is an Hash Table, so it is preferred to the Collection object when you need to access elements in the collection by key.
In addtion it has few properties and methods that the Collection object is lacking.
An alternative to the collection object is the scripting.Dictionary object which you can find adding a reference to the Microsoft Scripting Runtime.
The Dictionary Object is an Hash Table, so it is preferred to the Collection object when you need to access elements in the collection by key.
In addtion it has few properties and methods that the Collection object is lacking.
Thursday, November 11, 2010
How to read write and save to a config file in C#
Here you can find some c# code to read/write/save to a config file in c#.
Please note that you need to add a reference to
References -> Add Reference -> System.Configuration
and
using System.Configuration.
In Addtion you need to add an application configuration file
Please note that you need to add a reference to
References -> Add Reference -> System.Configuration
and
using System.Configuration.
In Addtion you need to add an application configuration file
Wednesday, September 8, 2010
How to create custom collection in VBA tricks
This post has been update here
You can find attached here the code that shows you how to create a strongly typed collection in VBA that has both a default Item property and that can be iterated with the For Each Loop.
As you will see from this blog post, some vba attributes are needed to be assigned to specific Collection properties, however these are not visible in the VBA IDE, but you can see them using notepad.
This solution was taken from a forum entry I found on the web
In VBA You can create both a defaul property and a default enumerator, but the process is a bit more manual.
If you export a .cls file from one of your VB6 proceedures and view it in a Notepad, you'll notice that some Attributes, not visible while editing your code, are added to the top of the routine(s).
The two properties in question will look something like this:
Property Get Item(Index As Variant) As Parameter
Attribute Item.VB_UserMemId = 0
Set Item = m_Collection.Item(Index)
End Property
Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
Set NewEnum = Me.mCollection.[_NewEnum]
End Property
It is important to note that the Attribute directive are just below the Property Signatures.
If they are not there, the code will not work.
Now the above all looks "normal" except for the addition of the three "Attribute" Lines.
In the Item Property the line "Attribute Item.VB_UserMemId = 0" makes it the default property.
In the NewEnum, the "Attribute NewEnum.VB_UserMemId = -4" makes it the Default Enumeration Property (I'm sure you recognize the "-4" part.)
The Attribute NewEnum.VB_MemberFlags = "40" is to make the Enumerator a Hidden property, but, technically, this is not recognized in VBA, so it will be visible in IntelliSense, but I don't find that a big deal.
The solution is to (1) Make your Class, (2) SAVE, (3) Export the Class, (4) Remove the Class (steps 3 and 4 can be combined into one, as it asks you if you wish to "Export" when you right-click and choose "Remove") and then (5) Manually add the Attribute Lines as shown above, (6) Re-Import the edited Class.
As for one comment in this post another way is
1) Add those attributes in the VBA IDE. You will get a syntax error. Ignore it
2) Click on the Class and Remove
3) Say Yes when you are asked to Export it
4) Import it again
Pay attention to not delete the class. Otherwise do: Export, Delete, Import.
(Btw, you can add the Attribute NewEnum.VB_MemberFlags = "40" line if you wish -- it won't hurt anything -- but it won't be recognized in VBA, it will just be quietly ignored. So there's no reason to bother doing this, really.)
As you know, editing the code thereafter has some propensity to lose these properties (even in VB6) and so this may have to be repeated occassionally. (A bit of a pain.)
The alternative is to create your class 100% within VB6 and then import it into your VBA Project.
Or, even better, make it in VB6, debugg it, get it running 100%, compile to DLL and then add this DLL to your references. This last concept is probably the most solid, but there could be deployment issues as your DLL now has to be correctly Registered on the Client machine. Not that this is a big problem, but it's not as easy as distributing a VBA Project...
You can find attached here the code that shows you how to create a strongly typed collection in VBA that has both a default Item property and that can be iterated with the For Each Loop.
As you will see from this blog post, some vba attributes are needed to be assigned to specific Collection properties, however these are not visible in the VBA IDE, but you can see them using notepad.
This solution was taken from a forum entry I found on the web
In VBA You can create both a defaul property and a default enumerator, but the process is a bit more manual.
If you export a .cls file from one of your VB6 proceedures and view it in a Notepad, you'll notice that some Attributes, not visible while editing your code, are added to the top of the routine(s).
The two properties in question will look something like this:
Property Get Item(Index As Variant) As Parameter
Attribute Item.VB_UserMemId = 0
Set Item = m_Collection.Item(Index)
End Property
Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
Set NewEnum = Me.mCollection.[_NewEnum]
End Property
It is important to note that the Attribute directive are just below the Property Signatures.
If they are not there, the code will not work.
Now the above all looks "normal" except for the addition of the three "Attribute" Lines.
In the Item Property the line "Attribute Item.VB_UserMemId = 0" makes it the default property.
In the NewEnum, the "Attribute NewEnum.VB_UserMemId = -4" makes it the Default Enumeration Property (I'm sure you recognize the "-4" part.)
The Attribute NewEnum.VB_MemberFlags = "40" is to make the Enumerator a Hidden property, but, technically, this is not recognized in VBA, so it will be visible in IntelliSense, but I don't find that a big deal.
The solution is to (1) Make your Class, (2) SAVE, (3) Export the Class, (4) Remove the Class (steps 3 and 4 can be combined into one, as it asks you if you wish to "Export" when you right-click and choose "Remove") and then (5) Manually add the Attribute Lines as shown above, (6) Re-Import the edited Class.
As for one comment in this post another way is
1) Add those attributes in the VBA IDE. You will get a syntax error. Ignore it
2) Click on the Class and Remove
3) Say Yes when you are asked to Export it
4) Import it again
Pay attention to not delete the class. Otherwise do: Export, Delete, Import.
(Btw, you can add the Attribute NewEnum.VB_MemberFlags = "40" line if you wish -- it won't hurt anything -- but it won't be recognized in VBA, it will just be quietly ignored. So there's no reason to bother doing this, really.)
As you know, editing the code thereafter has some propensity to lose these properties (even in VB6) and so this may have to be repeated occassionally. (A bit of a pain.)
The alternative is to create your class 100% within VB6 and then import it into your VBA Project.
Or, even better, make it in VB6, debugg it, get it running 100%, compile to DLL and then add this DLL to your references. This last concept is probably the most solid, but there could be deployment issues as your DLL now has to be correctly Registered on the Client machine. Not that this is a big problem, but it's not as easy as distributing a VBA Project...
Thursday, September 2, 2010
Mail Merge with multiple To, CC, distribution lists and changing Subject
Link to Advance Mail Merge.doc
Link to Advanced Mail Merge DB.xls
In this two files you will find a way to extend the MS World mail merge to send email to
1) Have multiple mails and distribution list in the To field
2) Have multiple mails and distribution list in the CC field
3) Have a chaning subject
Also nothe the the merged field in the .doc document can be formatted
1) To format a date, toggle the field and add \@"DD MMMM, YYY"
2) To format a number add \##,##
In the attached document you will find an example.
Link to Advanced Mail Merge DB.xls
In this two files you will find a way to extend the MS World mail merge to send email to
1) Have multiple mails and distribution list in the To field
2) Have multiple mails and distribution list in the CC field
3) Have a chaning subject
Also nothe the the merged field in the .doc document can be formatted
1) To format a date, toggle the field and add \@"DD MMMM, YYY"
2) To format a number add \##,##
In the attached document you will find an example.
Sunday, July 4, 2010
Example of VBA code formatting using manoli.net
if you go to this website http://www.manoli.net/csharpformat/ you will be able in a breeze to parse your VBA/C# code in HTML format. You can see at the bottom of this blog post an example.
To make it work in blogspot, you just need to go in Design -> Edit HTML and just after
<b:skin><




