cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Script Automate via Excel Macro

0 Kudos

Hi,

I have recorded attached script and save as .vbs format when i run the macro i am getting error ( attached is the screen shot of error).

Also can you please help me how to run this script through excel macro because right now i have to manually edit the the date in script and then run the script.

session.findById("wnd[0]/usr/ctxtSO_AUGDT-LOW").text = "10.09.2015"

session.findById("wnd[0]/usr/ctxtSO_AUGDT-HIGH").text = "15.09.2015"

I want to above date function under excel  so i can just change the date in excel and the run the Macro.

Please guide me how to run the SAP script through excel macro. I am using excel 2013 version.

Hope i am able to explain my query.

Thanks in advance!!!!

Thanks,

Rahul

Accepted Solutions (0)

Answers (2)

Answers (2)

0 Kudos

Hi Thomas,

Any update on code?

Thanks,

Rahul

thomas_brutigam2
Active Participant
0 Kudos

Hi Rahul,

there are tow different Ways to for your first Problem (Date)

First you can use a InputBox for each Date


min_dat= InputBox("Insert Minimal Date")

if min_dat <> False or min_dat<> "" then

session.findById("wnd[0]/usr/ctxtSO_AUGDT-LOW").text = min_dat

end if

Same goes for the High-Date

or you can calculate the Dates via DateAdd and format the Dates via Format:


session.findbyID("wnd[0]/usr/ctxtSO_AUGDT-LOW").text = Format(Now),"dd.mm.yyyy")

session.findbyID("wnd[0]/usr/ctxtSO_AUGDT-HIGH").text =Format(DateAdd("d",5,now),"dd.mm.yyyy")

Greetings

Thomas B

0 Kudos

1.Hi Thomas,

Thanks for your reply.

Can you please guide me how to use InputBox in my code? and for second code when i replace the code i got error in excel " Syntax error".

Now i know to how to run SAP script through excel. I have attached the code file. There are two code.

1.Now i want the code for save SAP excel export report to my PC with desired name for both code.

2.Once first code is complete the second code will run automatically

3.The date in second code line 18 & 19 run through excel aur automate instead of go to code and change date every time.

Hope I am able to understand my query.

Thanks in advance !!!!!

Rahul

thomas_brutigam2
Active Participant
0 Kudos

Rahul Chure wrote:

1.Hi Thomas,

Thanks for your reply.

Can you please guide me how to use InputBox in my code?

and for second code when i replace the code i got error in excel " Syntax error".

Now i know to how to run SAP script through excel. I have attached the code file. There are two code.

1.Now i want the code for save SAP excel export report to my PC with desired name for both code.

2.Once first code is complete the second code will run automatically

3.The date in second code line 18 & 19 run through excel aur automate instead of go to code and change date every time.

Hope I am able to understand my query.

Thanks in advance !!!!!

Rahul

Hi Rahul,

I think i understand your Problem-

First of all "InpoutBox" is a Function in VB(A) (S) that prompts a Box in which the User (you) can put any thing you're asking for.tt

The Syntax to call it: InputBox ([Prompt],[Title],[Default])

The Returnvalue of the InputBox is the Value youve typed in (and Press Ok) or False if you Press Abort

By the Way -
a simple way to shorten the Codings and spare many typing is to use a Keyword "With"


I've updated your Code a bit and built in a way to handle with Inputboxes-
this should work at least (cant test it because dont have currently Acces to SAP)

greetings

Thomas

0 Kudos

Hi Thomas,

Getting error "Argument not optional" under line MsgBox.

i think in your code i can't save automatically SAP export excel file to my drive.

Thanks for the help

Rahul

thomas_brutigam2
Active Participant
0 Kudos

damn
that should have been:

Msgbox "Not a Valid Date",vbokonly

0 Kudos

Hi,

Again error 😮 "Label not defined" under line GoTo Typemindate.

Rahul

thomas_brutigam2
Active Participant
0 Kudos

Did you Copy / Paste the Code ?

or typed the whole thing?

Is there a ":" behind the first typemindate ? shoud be
otherwise it should work ?

PS now on Holiday - won't check my Email for 2 weeks

Good Luck...

0 Kudos

Hi Thomas,

Attached is the code i am using.

But show the error "Label not defined" on code line "GoTo Typemindate"

I think i am missing something.

Thanks,

Rahul

holger_khn
Contributor
0 Kudos

Hello.

this is an issue with Label of GoTo-statement,

Use numbers as Expression:

************************************************************************************************

.....

10:

    min_date = InputBox("Please insert Minimum-Date")

    If min_date <> "" Or min_date <> False Then

        If IsDate(min_date) Then

        .findById("wnd[0]/usr/ctxtSO_AUGDT-LOW").Text = min_date

        End If

        Else

        MsgBox "Not a Valid Date", vbOKOnly

        GoTo 10

    End If

20:

    max_date = InputBox("Please Insert Maximum Date")

    If max_date <> "" Or max_date <> False Then

        If IsDate(max_date) Then

        .findById("wnd[0]/usr/ctxtSO_AUGDT-HIGH").Text = max_date

            Else

            GoTo 20

        End If

        Else

        GoTo 20

    End If

.....

************************************************************************************************