santa12345
Board Regular
- Joined
- Dec 2, 2020
- Messages
- 70
- Office Version
- 365
- Platform
- Windows
hello.
I am trying to do the following.
Within Access using VB to....
1. open up an excel file
2. copy and paste special (the exact same data to the exact same tab) ... just removing the formulas
3. save the file with the same name (skipping / don't want the excel prompts to display....etc..
4. close the file and copy to another location
Dim objExcelApp As Excel.Application
Dim wb As Excel.Workbook
Set objExcelApp = Excel.Application
Set wb = objExcelApp.Workbooks.Open("c:\ABC\123.xls")
objExcelApp.Visible = True
wb.Sheets("tab A").Select
wb.Sheets("tab A").Range("a1:aa2000").Copy
wb.Sheets("tab A").Range("A1:aa2000").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Sheets("tab B").Select
wb.Sheets("tab B").Range("a1:aa2000").Copy
wb.Sheets("tab B").Range("A1:aa2000").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Sheets("tab C").Select
wb.Sheets("tab C").Range("a1:aa2000").Copy
wb.Sheets("tab C").Range("A1:aa2000").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Application.DisplayAlerts = False
wb.Save
wb.Application.DisplayAlerts = True
wb.Close
Dim SourceFile, DestinationFile
SourceFile = "c:\ABC\123.xls"
DestinationFile = "c:\DEF\456.xls"
FileCopy SourceFile, DestinationFile ' Copy source to target.
I am trying to do the following.
Within Access using VB to....
1. open up an excel file
2. copy and paste special (the exact same data to the exact same tab) ... just removing the formulas
3. save the file with the same name (skipping / don't want the excel prompts to display....etc..
4. close the file and copy to another location
Dim objExcelApp As Excel.Application
Dim wb As Excel.Workbook
Set objExcelApp = Excel.Application
Set wb = objExcelApp.Workbooks.Open("c:\ABC\123.xls")
objExcelApp.Visible = True
wb.Sheets("tab A").Select
wb.Sheets("tab A").Range("a1:aa2000").Copy
wb.Sheets("tab A").Range("A1:aa2000").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Sheets("tab B").Select
wb.Sheets("tab B").Range("a1:aa2000").Copy
wb.Sheets("tab B").Range("A1:aa2000").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Sheets("tab C").Select
wb.Sheets("tab C").Range("a1:aa2000").Copy
wb.Sheets("tab C").Range("A1:aa2000").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
wb.Application.DisplayAlerts = False
wb.Save
wb.Application.DisplayAlerts = True
wb.Close
Dim SourceFile, DestinationFile
SourceFile = "c:\ABC\123.xls"
DestinationFile = "c:\DEF\456.xls"
FileCopy SourceFile, DestinationFile ' Copy source to target.