'VBA Inserts extra parenthesis when copying Module to Another WorkBook

So as the title states VBA is adding an extra set of parenthesis after it moves code over. Why does it do this? And how do i make it stop?

Here is code moving the module:

Set src = ThisWorkbook.VBProject.VBComponents("Module2").CodeModule
Set dest = ActiveWorkbook.VBProject.VBComponents("Sheet2") _
.CodeModule

dest.DeleteLines 1, dest.CountOfLines
dest.AddFromString src.Lines(1, src.CountOfLines)

Here is the code after the output:

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, _
ByVal nShowCmd As Long) As Long

 Private Sub MESSAGEBERX()
      MsgBox ("You did it")
 End Sub
 ()

EDIT

turns out I left out the the stuff at the top. It also turns out that the culprit was it. Is it due to the "private function" part? I am still messing around with it but still cant get it to move over without the extra parentheses...



Solution 1:[1]

I've had the same problem. Another workaround is to make the declare part at the top one line, i.e., without "_".

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 dks