H
Horatio J. Bilge, Jr.
I am using vba in one workbook to make changes in a target workbook. I used
application.cutcopymode=false to clear the clipboard, but it doesn't seem to
work correctly. I have the clipboard visible to the side of the window, and
all of the copy/paste operations remain in the clipboard.
Here is the code I am using:
Option Explicit
Sub auto_open()
Dim FileName As Variant
Application.ScreenUpdating = False
FileName = Application.GetOpenFilename
If FileName = False Then Exit Sub
Dim WB As Workbook
Set WB = Workbooks.Open(FileName)
ThisWorkbook.Worksheets("Sheet1").Activate
ActiveSheet.Cells.Copy
WB.Worksheets("Sheet1").Range("A1").PasteSpecial
WB.Worksheets("Sheet2").Range("A33").Copy
WB.Worksheets("Sheet2").Range("A44").PasteSpecial xlPasteFormats
WB.Worksheets("Sheet2").Range("B5:G5").Copy
WB.Worksheets("Sheet2").Range("B7:G9").PasteSpecial xlPasteFormats
Application.CutCopyMode = False
WB.Worksheets("Sheet1").Activate
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
ThisWorkbook.Close savechanges:=False
End Sub
application.cutcopymode=false to clear the clipboard, but it doesn't seem to
work correctly. I have the clipboard visible to the side of the window, and
all of the copy/paste operations remain in the clipboard.
Here is the code I am using:
Option Explicit
Sub auto_open()
Dim FileName As Variant
Application.ScreenUpdating = False
FileName = Application.GetOpenFilename
If FileName = False Then Exit Sub
Dim WB As Workbook
Set WB = Workbooks.Open(FileName)
ThisWorkbook.Worksheets("Sheet1").Activate
ActiveSheet.Cells.Copy
WB.Worksheets("Sheet1").Range("A1").PasteSpecial
WB.Worksheets("Sheet2").Range("A33").Copy
WB.Worksheets("Sheet2").Range("A44").PasteSpecial xlPasteFormats
WB.Worksheets("Sheet2").Range("B5:G5").Copy
WB.Worksheets("Sheet2").Range("B7:G9").PasteSpecial xlPasteFormats
Application.CutCopyMode = False
WB.Worksheets("Sheet1").Activate
ActiveSheet.Range("A1").Select
Application.CutCopyMode = False
Application.ScreenUpdating = True
ThisWorkbook.Close savechanges:=False
End Sub