Convert VBA to VBScript

Hi HPE and all…

I am looking for some sample code/directions for getting some complex VBA Macro converted into a vbs script. But I am not able to find any document/posts that have details about things that one can do in a vbs script.
Would you be kind enough to share something plz?
Looking forward to your response.

Thanks,
Buddy.


Buddy :india: (BOB member since 2006-08-04)

A vbscript uses the same object model as VBA, so I would expect functionality to be quite similar. Without more details on your “complex” macro though, it would be hard to know if you’ll find any limitations.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

Hey thanks for prompt response…
Firstly I don’t know of any editor software in which I can write vbscript. BO Tech Support site has only 1 sample code (to delete report) and they tell us to open a notepad and save as .vbs.
Now for instance I do this in VBA,

Dim l_Document As Document
Set l_Document = Application.Documents.OpenFromEnterprise(“Daily_Activity_Report”, “Development”, boFolder)

This doesn’t work as it is in vbs. And more frustratingly, I am not able to find anything that can give me some clue. No documentation/no sample code, nothing. I may be lacking in doing a good search but I dont think so.
Please assist.

Thanks,
Buddy.


Buddy :india: (BOB member since 2006-08-04)

Correct, there is no IDE (integrated development environment) for vbscript built in to Windows. While I have no specific recommendations, there are plenty of third party editors that you can purchase for this purpose. You can also find plenty of vbscript support forums via Google, etc.


Dwayne Hoffpauir :us: (BOB member since 2002-09-19)

In VBscript you have to create instance of each object, even application.

Try something like this:

Dim BusobjApp, BusobjDoc

set BusobjApp=CreateObject(“Businessobjects.Application”)

Set BusobjDoc = BusobjApp.Documents.OpenFromEnterprise(“Daily_Activity_Report”, “Development”, boFolder)


rachidb :morocco: (BOB member since 2006-07-06)

Hi rachidb,

Thanks a lot for your response. Now I think I am slowly getting a hold of vbscript. I went few more posts and tried to combine the knowledge from all of them to get my script working. However, I am stuck at one point now…
Please have a look at the below code, which is very straight forward and I expect it to work.


dim appint 
dim objDoc 

Set appint         = CreateObject("BusinessObjects.Application") 
appint.Visible     = False
appint.Interactive = False 

appint.LoginAs "Administrator", "", FALSE
Set objDoc = appint.Documents.OpenFromEnterprise("Daily_Activity_Report", "Development", boFolder)

objDoc.Refresh 
objDoc.SaveAs ("C:\Daily_Activity_Report.pdf")
objDoc.Close 
      

appint.Interactive = True 
appint.Quit 

Set appint = Nothing 
Set objDoc = Nothing

However, that code does not successfully execute the LoginAs line and fails :wah:
I am not 100% sure as to what/how many parameters does the LoginAs require, so what I have written above is a copy+paste from other posts.
Please note that we are on XI R2 SP2.

I have tried a lot of other parameters and changed the sequence of the paramertes etc. But nothing seems to work.
Some of the other things that I have tried are…

appint.LoginAs “Administrator”, “”
appint.LoginAs “Administrator”, “”, “Enterprise”
appint.LoginAs “Administrator”, “”, “SERVERNAME”, “Enterprise”
appint.LoginAs “Administrator”, “”, “FULL.SERVER.NAME.COM”, “Enterprise”
appint.LoginAs “SERVERNAME”, “Administrator”, “”, “Enterprise”
appint.LoginAs “FULL.SERVER.NAME.COM”, “Administrator”, “”, “Enterprise”

each time I get an error, which says,

Script: C:\test4.vbs
Line: 8
Char: 1
Error: LoginAs failed
Code: 800A0132
Source: Desktop Intelligence

Please could you (or anyone else) help?!

Thanks in advance,
Buddy.


Buddy :india: (BOB member since 2006-08-04)

In BOXIR2 synthax of the logon function is as follows:
Function Logon(User As String, Pass As String, CMS As String, mode As String, ThreeTier As Boolean, Offline As Boolean) As Boolean
Member of busobj.Application
Unfortunately I don;t have examples ready but you can check the Deski SDK for more details.

Rachid


rachidb :morocco: (BOB member since 2006-07-06)