Hi,
I have some code to massage excel workbook in an access VBA script.
I copied some code from this site re-copying sheet to new workbook which I have been attempting to modify.
At this stage I have two problems.
1(. The new workbook has no data.
2(. I get a pop up message saying that I have a large amount of data in the clipboard, (I thought this code disabled that)
Here is the code of the subroutine.
I have some code to massage excel workbook in an access VBA script.
I copied some code from this site re-copying sheet to new workbook which I have been attempting to modify.
At this stage I have two problems.
1(. The new workbook has no data.
2(. I get a pop up message saying that I have a large amount of data in the clipboard, (I thought this code disabled that)
VBA Code:
Dim excelapp As Object, wb As Object, ws As Object, ws2 As Object
excelapp.CutCopyMode = False
Here is the code of the subroutine.
Code:
Sub MySheetCopy(SBName)
Dim mySourceWB As Workbook
Dim mySourceSheet As Worksheet
Dim myDestWB As Workbook
Dim myNewFileName As String
Dim stPathName As String
Dim excelapp As Object, wb As Object, ws As Object, ws2 As Object
Set excelapp = CreateObject("excel.application")
' First capture current workbook and worksheet
Set mySourceWB = ActiveWorkbook
Set mySourceSheet = ActiveSheet
stPathName = "C:\RSL LogBookMgmt\LogBook files\Reports\"
' Build new file name based
myNewFileName = stPathName & SBName & " Monthly Charitable Activities Form.xlsx"
Workbooks.Add
ActiveWorkbook.SaveAs Filename:=myNewFileName
Set myDestWB = ActiveWorkbook
' Copy over sheet from previous file
mySourceWB.Activate
Cells.Copy
myDestWB.Activate
Range("A1").Select
'ActiveSheet.Paste
With Workbooks.Add.Sheets(1).Range("A1")
.PasteSpecial Paste:=xlPasteValuesAndNumberFormats
End With
excelapp.CutCopyMode = False
mySourceWB.Close savechanges:=True
myDestWB.Close savechanges:=True
End Sub