All Forums >> [Scripting] >> WSH & Client Side VBScript >> 'variable is undefined' runtime error Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Hi, I am a newbie and am getting the above error for the object 'PeachtreeAccounting' when I run the following code.
Dim Login Set Login = CreateObject("PeachtreeAccounting.Login.16") Dim App Set App = Login.GetApplication("COMPANY NAME", "M48FT9X2A") Dim CustomerExporter Set CustomerExporter = PeachtreeAccounting.Export ********* this is the line on which I get the error********************* CustomerExporter = App.CreateExporter(PeachtreeAccounting.PeachwIEObj.peachwIEObjCustomerList)
I should explain that PeachtreeAccounting is an accountancy package; in order that I can export their data I create a login object which starts up the application. That part works; I run the script and the package opens. Peachtree say I should have to register no more files because the relevant files are exposed through the application.
I have googled this and the solution mainly seems to be misspellings (which I have checked) or the fact that Option Explicit is turned on. The latter is true but as this exerpt is part of another script which I am not allowed to alter, that solution is not possible.
As 'PeachtreeAccounting.Export' is an object, I assume I have to treat it differently to declaring a variable, but how?
I would be grateful if anyone could point me in the right direction.
not knowing anything about Peachtree, I may be wrong, but I'd try
Dim Login Set Login = CreateObject("PeachtreeAccounting.Login.16") Dim App Set App = Login.GetApplication("COMPANY NAME", "M48FT9X2A") Dim CustomerExporter Set CustomerExporter = App.CreateExporter( App.PeachwIEObj.PeachwIEObjCustomerList ) CustomerExporter.Export
assuming that .Login gives you an application and the application gives you everything else.
If you can use Excel, you can add a references to your Peachtree .dll to a module and use the object browser to lookup objects, methods, and properties.
Hi ehvbs, Thanks again for your help. When I try your suggestion I get the error msg 'Object doesn't support this property or method: App.PeachwIEObj' which sounds like it can't find the COM object.
I have checked the registry and can find no object called PeachtreeAccounting.Export though I did find PeachtreeAccounting.Login.16 which is the one I created. I assume I should be able to find the Export object if I am supposed to be referring to it?
I've decided to go down the route of wrapping the export function in a .NET dll and instantiating it from within my VBscript program. The VBscipt program is simply not picking up the objects provided by Peachtree.