Workbooks(1).Activate doesn't work with VBA macro in LO-Calc?

Hey,

I have a VBA-Macro which in principle is working in LibreOffice when it is saved within a *.xlsm document - it makes what it should (copy some values between one worksheet to another worksheed of the same document=workbook).
It starts like this:

Option VBASupport 1
Sub MyMacro1()
  Dim Source As Worksheet 
  Dim Target As Worksheet
  Set Source = ActiveWorkbook.Worksheets(1)
  Set Target = ActiveWorkbook.Worksheets(2)
  '..... copying some cells ..... works! ....
End Sub 

Now I want not anymore to store the macro code within the xlsm-document but want to move it to the “my macro” section within the “BASIC-Macro” dialogue. So I copied the working macro code to a new macro within “MyMacros → MacroNameXY → Module1” and MyMacro1 is shown up and I can edit it.

But I can’t figure out how to add the part to first activate the only open workbook to further run my code within it. I thought I only need to pick the correct workbook and to make it active and then the rest of my code should work as before. I tried this but without success:

Option VBASupport 1
Sub MyMacro1()
  Dim Source As Worksheet
  Dim Target As Worksheet
  Dim wb As Workbook

  Set wb = Workbooks("myfile.xlsx")
  wb.Activate 
  Set Source = ActiveWorkbook.Worksheets(1)
  Set Target = ActiveWorkbook.Worksheets(2)
  '..... copying some cells ..... NOT Working ....
End Sub 

I get the error message (translated german–>eng):
“BASIC Runtime error.
‘35’
Procedure Sub or Function not defined.
Additinal information: Workbooks”

And the code line Set wb = Workbooks("myfile.xlsx") is highlighted.

Can anybody help my how to proceed?

My main goal is just to run me working script which is not saved in the workbook/file to process but which is stored in the “MyMacro” of OO place (where ever this exactly is) - but I think I have to activate first the only open workbook… but how?

What I indeed first tried to just run the first macro as it is like this:

Sub MyMacro()
  Dim Source As Worksheet
  Set Source = ActiveWorkbook.Worksheets(1)
  '......
End Sub

But it ends with the error message at the line Set Source = ActiveWorkbook.Worksheets(1):
“BASIC Runtime error.
‘91’
Object variable not assigned”
Therefore I tried the first mentioned activate procedure… but without luck…

Thanks for any hints where a knot in my mind is…
Cheers, Robert