0

I'm doing macro with connection but this syntax error appeared:

End of Statement

I tried to duplicate the quotation marks but unsuccessfully, another error appeared.

LINHA = 11
Cells(11, 1).Select

Cells(LINHA, 2).Value = session.findById("wnd[0]/usr/shell/shellcont[1]/shell[1]").Text"          2", "&Hierarchy"
Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
  • 1
    VBA is expecting `.Text` to terminate the statement; it doesn't know what to do with the `" 2"", "&Hierarchy"` string that follows. Missing a comma after `.Text`, maybe? – Mathieu Guindon Jun 13 '19 at 21:16
  • I just tried , and the same error happen – Lucas Miazato Jun 13 '19 at 21:22
  • `= session.findById("...").Text` is a statement. I've no idea what you mean to do with the rest off the line of code - is that meant to be another parameter to `findById`? In that case it needs to be within the `(...)` parenthesized argument list. – Mathieu Guindon Jun 13 '19 at 21:23
  • Hi , It would be a path to a certain part of SAP , ("wnd[0]/usr/shell/shellcont[1]/shell[1]").Text" 2", "&Hierarchy" = It is the field in a finished part of the SAP – Lucas Miazato Jun 17 '19 at 13:01

1 Answers1

0

Syntactically, you have essentially this (depending which revision of the post we're looking at):

Object.Property = Object.Method(arguments).Property"some stray string literal", "another string literal"
                                                   ^ end of statement expected here

While this is a legal statement:

Object.Property = Object.Method(arguments).Property

Either remove the stray string literal, or make it part of the arguments to the findById method - I don't know the SAP API, but since you're coding against it you should have access to some documentation explaining what the expected arguments are.

This code will compile - again I have no idea what the SAP API wants to see, so it might blow up at run-time, but at least it's legal code:

ActiveSheet.Cells(LINHA, 2).Value = session.findById("wnd[0]/usr/shell/shellcont[1]/shell[1]", 2, "&Hierarchy").Text
Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
  • Hi , i try use your code , but now the error is: "Wrong number of arguments or invalid property assignment" . – Lucas Miazato Jun 17 '19 at 13:04
  • Like I said, I don't have an SAP library and I'm not familiar with the SAP API - if that's a compile-time error then the library is referenced and the `session` member call is early-bound - you can re-type the `(` opening parenthesis after `findById` or press Ctrl+i to see what parameter(s) it's expecting, and work with that. Look at the SAP API documentation for `findById` if you're unsure what the argument(s) need to be. – Mathieu Guindon Jun 17 '19 at 14:33