Typing with a vbs script

hello all, thanks again for all the help!

so im trying to learn vbs scripting and im trying to write the date and time in a specifc cell.

from what i saw at google this should be enough in the file:

Sub InsertDate(param)
Range(param).Value = Date
End Sub

(this is my entire vbs file)
param is the cell i want. i passed in uipath the cell i want as a paramater, i also allowed excel to use the scripting in the settings.

any ideas why its not working? nothing changes in the excel and all i get is an error sound from windows.

@wsm1
do this

  1. paste below code in file vba.txt
Sub InsertDate(param)
Range(param).Value = Date
End Sub
  1. in excel application scope, call invoke VBA activity, pass in parameter as follows
    after invoke vba, call save workbook activity

Testx.xaml (9.5 KB)

1 Like

thank you for your comment.

im trying this. i also changed to excel application scopre (i worked on excel process scope), but now it says it cannot access the excel because it being used by another proccess.
but the excel is close

can you kill excel in task manager and try again?

its not open in the task manager proccess tab
so weird, ill try updating windows maybe

ok, can you also upload your .xaml file here?

im trying to look for it, its the main now?

i managed to see the problem. the “Read cell” activity says that its taken already. so the excel application scope its holding it… cant i work with both of them together?

just upload the .xaml containing this logic (invoke vbs etc…)

you can work with them together, but let me take a look at your .xaml first

1 Like

ok i found im sending

you have to use this read cell
image

i have changed all your read cell activities see below

Excel File Close.xaml (93.2 KB)

1 Like

amazing! any idea why what i chose didnt work?
also do you know how i can also insert time?

thank you!!!

1 Like

change code to this (just replace “Date” with “Now” , then it will add the time

Sub InsertDate(param)
Range(param).Value = Now
End Sub

it didnt work for you because the read cell activity you used is wrong, you should use the one that doesnt need you to input the filepath
the one you used (with filepath) will open the file, read cell and close file. This wont work because you already used excel application scope to open excel file, so you cant open the file again
image

whereas the one i used (no filepath) will read from existing file (opened by excel application scope) so it works
image

1 Like

thank you jack.chan, you helped me so much!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.