(Solved) – Save clipboard when closing workbook vba

(solved)-–-save-clipboard-when-closing-workbook-vba

It seems like a easy question, yet I can’t seem to find the correct answer on Google.

What I want to do is open a workbook, copy a section and then close the workbook while saving the section I just copied.

I’m aware of the function to disable the clipboard prompt:

Application.CutCopyMode = False
ActiveWindow.Close

But this does not save the clipboard. Thus far I have written the following code to do so:

Sub Input()

Application.ScreenUpdating = False

Dim wb As Workbook
Dim wbPad As String

On Error GoTo ErrHandler

wbPad = ThisWorkbook.Sheets("Voorblad").Range("C10").Value
    Set wb = Workbooks.Open(wbPad)

    Cells.Select
    Selection.Copy
    Windows("Masterfile.xlsm").Activate
    Worksheets("INPUT").Activate
    Cells.Select
    ActiveSheet.Paste
    Range("A1").Select
    Worksheets("Voorblad").Activate

Exit Sub

ErrHandler:
    MsgBox ("Bestand niet gevonden. Controleer de maand en de naam van het bestand dat je wilt openen")

End Sub

If this is not possible, I would like to .Activate the workbook I opened using the cell reference and close this.

Thanks in advanced!

Leave a Reply

Your email address will not be published. Required fields are marked *