Dear Professionals
I wish to write a macro to do the following steps:
1. open a (fileA) (undefined type) with excel.
2. After opened the file, copying the content into the active workbook (Database).
I have tried the following code, it fails
Sub openQIR()
'
' openQIR 巨集
'
Dim wbSource As Workbook, wbDestination As Workbook
Set wbSource = Workbooks.Open("C:\user\desktop\tatfish\fileA.xlsx")
Set wbDestination = ThisWorkbook
With wbSource.Sheets(1).Select
Range("A1:H1", Range("A20000:H20000").End(xlUp)).Select
Selection.Copy
Windows("Database.xlsm").Activate
Sheets("2").Select
Range("A" & Rows.Count).End(xlUp).Offset(2).Select
Selection.PasteSpecial Paste:=xlPasteValues
Selection.PasteSpecial Paste:=xlPasteFormats
Application.CutCopyMode = False
End With
Sheets("1").Select
'Close source:
wbSource.Close
'
End Sub
I understand it must fail because the type of fileA is not .xlsx
The file A is underfined type but it can be opened with excel (currently do it manually).
Please kindly teach me to amend my code for making it done.
Thousands thanks.
Bookmarks