Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


vbscript capability

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,64426
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript capability
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1] 2   next >   >>
Login
Message << Older Topic   Newer Topic >>
 vbscript capability - 9/21/2008 10:48:57 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Hi,

I'm new to the forum. I am relatively new to programming and normally work in .NET (C#) but need to work in vbscript for my next project.
My new project involves connecting to an application, exporting csv files from it, reading those files and performing simple mathematical calculations.
I have searched the forum and from previous posts it looks like these are possible in vbscript. Is this correct?

I would rather know now than find out later down the line that vbscript does not have capability for the above.

If it is possible, I have been supplied with some VB.NET scripts that apparently would help a lot. Is this also correct?

meerkat
 
 
Post #: 1
 
 RE: vbscript capability - 9/21/2008 11:17:28 PM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi meerkat,

(1) what exactly is "connecting to an application"? What application? Do you have to
      automate the export of .csv files?

(2) why do you have to use VBScript?

(3) are you allowed to 'publish' the .Net code?

Regards

ehvbs

(in reply to meerkat)
 
 
Post #: 2
 
 RE: vbscript capability - 9/21/2008 11:39:39 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Thanks for your reply.

A brief description of the project:-

I will remotely access a client's PC and aim to export data from their specific accounting package. The accounting package has provided an SDK which contains code in C# or VB.NET that can be used to export data in the form of csv files. I have to rewrite that their exporter code in vbscript. To answer your questions:

(1) Part of the package's exporter function involves remotely logging in to the package using a username and login. Without this the data cannot be exported.
(2) We need to use vbscript because there will be hundreds of clients and I understand that with vbscript nothing more will need to be installed on the client's PC. (Unlike .NET).
(3) Do you mean am I allowed to put it on this forum? If so, there should be no problem with that.

Hope that gives you a better idea! As long as I know that all this is possible in vbscript, I am looking forward to finding out how. 

Many thanks,

meerkat


(in reply to meerkat)
 
 
Post #: 3
 
 RE: vbscript capability - 9/21/2008 11:57:08 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
For example, this is the VB.NET code used to login to the accounting package. Can this be converted into vbscript?
'Define the application variable to be used throughout the program
 
Public App As AppleAccounting.Application
 
'Define the login variable that is used to login to Apple 
Public Login As New AppleAccounting.Login
 
Set App = Login.GetApplication("<Company Name>", "<Password>")
 
 
meerkat

(in reply to meerkat)
 
 
Post #: 4
 
 RE: vbscript capability - 9/22/2008 1:12:38 AM   
  Rischip


Posts: 502
Score: 2
Joined: 3/26/2007
Status: offline
VBScript does not support Variable Type Declarations. So "Public App As AppleAccounting.Application" would simply become "Dim App".
VBScript does support COM interfaces. So try creating the COM app like this....

Set App = CreateObject("AppleAccounting.Application")

and see what you can do with the object.


_____________________________

Rischip
Author of - The Grim Linker

(in reply to meerkat)
 
 
Post #: 5
 
 RE: vbscript capability - 9/22/2008 7:17:12 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi meerkat,

given:

  Public App As AppleAccounting.Application
Public Login As New AppleAccounting.Login
Set App = Login.GetApplication("<Company Name>", "<Password>")

I'd try:

Dim Login : Set Login = CreateObject( "AppleAccounting.Login" )
Dim App   : Set App   = Login.GetApplication("<Company Name>", "<Password>")

If something like this works and we can get those .csv files, I propose to use ADO
to process them.

Good luck!

ehvbs


(in reply to Rischip)
 
 
Post #: 6
 
 RE: vbscript capability - 9/22/2008 7:30:47 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
The advantage of csv is that it's a text based and therefore can be read through the File System Object. A much more convenient and faster way than using Excell.

_____________________________

Fred

(in reply to ehvbs)
 
 
Post #: 7
 
 RE: vbscript capability - 9/22/2008 9:06:45 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Fredledingue,

if you are refering to my proposal: ADO <> Excel.

Regards

ehvbs

(in reply to Fredledingue)
 
 
Post #: 8
 
 RE: vbscript capability - 9/22/2008 7:49:31 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Hi,

Thanks a lot.You've all been a great help. I get 'ActiveX component can't create object'on the Dim Login line when trying:

Dim Login : Set Login = CreateObject( "AppleAccounting.Login" )    
Dim App   : Set App   = Login.GetApplication("<Company Name>", "<Password>")

However, it looks like there is a lot of help for this online. Now that I know that the recoding is possible, I'll learn the basics of VBscript before trying it so that I don't waste other's time.

Thanks again!

meerkat

(in reply to meerkat)
 
 
Post #: 9
 
 RE: vbscript capability - 9/22/2008 8:10:36 PM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi meerkat,

please read

http://www.microsoft.com/technet/scriptcenter/guide/sas_vbs_masc.mspx?mfr=true

and make sure, this "AppleAccounting" supports late binding. If not, using VBScript won't
be possible.

Regards

ehvbs

(in reply to meerkat)
 
 
Post #: 10
 
 RE: vbscript capability - 9/22/2008 9:54:32 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Hi,

Thanks. I will find out if the accounting package supports late binding. In the meantime, can I please ask what is probably a very basic question.

Peachtree Accounting (the real name of the accounting package) supports COM objects. They say that we can use a VB.NET or C#.NET program or VB program to create a login object which obtains an Application object which in turn controls access to the COMs in the package.

I did access the objects successfully in my C# program but I had to use a couple of namespaces in my program. i.e.
using Peachtree;
using PeachtreeAccounting; 

In reality, when I ran my program it started up the package itself and accessed objects within it. It therefore appears that I need to access the above objects to start off with, then once I am 'in' the package itself I can access any object.
How do I get my vbscript to reference these objects in the same way?

I hope I have explained that OK.

meerkat

P.S. I think VB.NET would use 'Imports Peachtree' and 'Imports PeachtreeAccounting'. Does VBscript use this too?

(in reply to meerkat)
 
 
Post #: 11
 
 RE: vbscript capability - 9/22/2008 10:07:37 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
 
Please ignore my last post.  don't think my C# program does need those namespace references. All it needs to do is to create the login object and access the application.

(in reply to meerkat)
 
 
Post #: 12
 
 RE: vbscript capability - 9/22/2008 10:55:07 PM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi meerkat,

"using" just allows to use unqualified/shorter names; more important are the references.
They should point to the .dll(s) implementing Peachtree Accounting.

Are you sure these are registered on your testing computer? (not being registered could
explain the error message from your previous posting).

Good luck!

ehvbs

(in reply to meerkat)
 
 
Post #: 13
 
 RE: vbscript capability - 9/23/2008 1:54:10 AM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Hi,

When you say 'register' do you mean include script similar to below? I have included this script with the appropriate path and dll file.

Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.Run "regsvr32.exe c:\windows\system32\whatever.dll"


This is what I have currently. The error is: Variable undefined: 'Peachtree Accounting' (on the second line).

Dim Login
Set Login=CreateObject(PeachtreeAccounting.Login)
Dim App
Set App=Login.GetApplication("COMPANY NAME", "2M4899RFT915X2A")

Could this latest error be related to the fact that I haven't registered the dll file properly?

(in reply to meerkat)
 
 
Post #: 14
 
 RE: vbscript capability - 9/23/2008 3:07:21 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi meerkat,

CreateObject takes a string parameter, as you correctly did in:

  Set objShell = CreateObject("WScript.Shell")

So change

  Set Login=CreateObject(PeachtreeAccounting.Login)

to

  Set Login=CreateObject( "PeachtreeAccounting.Login" )

assuming that "PeachtreeAccounting.Login" is the valid ProgId (Check the
registry).

BTW, the regsrv32 action should be done just once on a machine.

Good luck!

ehvbs



(in reply to meerkat)
 
 
Post #: 15
 
 RE: vbscript capability - 9/23/2008 5:51:57 AM   
  Fredledingue


Posts: 383
Score: 0
Joined: 5/9/2005
From:
Status: offline
ehvbs,
no, I just wanted to say that it's more convenient, in my opinion, to read the csv file as atext file and manipulate the text strings on each line, than reading it via a tier application.

_____________________________

Fred

(in reply to ehvbs)
 
 
Post #: 16
 
 RE: vbscript capability - 9/23/2008 6:37:10 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Fredledingue,

(1) I agree that there are many cases in which processing a .txt/.csv file using
    native VBScript facilities (FileSystemObject, Split, Instr, Replace, RegExp, ...)
     is a convenient and efficient strategy.
        pros:
           no further software (e.g. Excel) to install/learn
           straightforward programming
           (as) fast (as VBScript can do)
       cons:
           problems with more complicated formats (embedded vbCrLf/delimiters)
           gets difficult if you have to access more than one file simultaneously
           gets difficult if the operations get more complicated

(2) Contrary to Excel, ADO is installed on (most) modern Windows computers

(3) meerkat mentioned ".csv files" exported from an application; that's why I
     thought of ADO to avoid the problems listed under cons above

(4) we should consider both approaches as soon as meerkat tells us more
     about his specs concerning the files.

Regards

ehvbs


          
          

(in reply to Fredledingue)
 
 
Post #: 17
 
 RE: vbscript capability - 9/24/2008 2:39:55 AM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Hi ehvbs,

Thanks for your advice of adding quote marks. Unfortunately I still get an error of 'ActiveX component can't create object Peachtree Login, on:
Set Login = CreateObject("PeachtreeAccounting.Login")

I think this is still a problem related to registering dll files.  To find out which dll file I needed to register I looked at the COM files provided by Peachtree and found one called PeachtreeAccounting. I used regsvr32 on the cmd line to successfully register the corresponding dll file but still get the same error as above.

I have also found a file called Interop.Peachtree.dll but when I tried registering it, I got the msg 'DllRegisterServer entry point was not found. This file can not be registered'. I googled this message and found that this is because the interop dll file is a .NET file rather than a COM object.

So, a couple of quick questions before I start registering every dll file I can find(!):
1. Is there any other way of finding out which file I should be registering?
2. Should I ignore interop files?

Many thanks,

meerkat
(not male by the way!)

(in reply to meerkat)
 
 
Post #: 18
 
 RE: vbscript capability - 9/24/2008 6:32:02 AM   
  ehvbs

 

Posts: 2169
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi meerkat,

I beg your pardon for the gender blunder - caused by thoughtlessness.

Googling  for "PeachtreeAccounting.Login", I found some hints that you
need to specify the version in the CreateObject call:

  Set Login = CreateObject("PeachtreeAccounting.Login.13")

Of course 13 may be the wrong version for your computer. Search the registry
for "PeachtreeAccounting" or "PeachtreeAccounting.Login" and make sure.

Good luck!

ehvbs

(in reply to meerkat)
 
 
Post #: 19
 
 RE: vbscript capability - 9/24/2008 8:16:08 PM   
  meerkat

 

Posts: 16
Score: 0
Joined: 9/21/2008
Status: offline
Hi ehvbs,

Bingo! I just tried various numbers at the end of 'PeachtreeAccounting.Login' until one of them worked. Thank you very much, though I am embarrassed that I didn't think of that!

Now I can get on with the rest of the script.

Thanks once again,

meerkat
P.S. Don't give a second thought to the gender mistake. Must be very common on these forums.

(in reply to ehvbs)
 
 
Post #: 20
 
 
Page:   [1] 2   next >   >>
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> vbscript capability Page: [1] 2   next >   >>
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts