Originally Posted by
sanjuss2
1. ...code for copying specific sheet of specific folder in another workbook
2. ... after running this it search documents in different path not in my given path strExtension showing value of C:\Users\lenovo\Documents & provide blank file as output
Ad 1. What you mean ?
Perhaps: "code for copying a specific sheet from one workbook, placed in a specific folder, to another (new) workbook" ?
Ad 2. From contextual help of vba:
"You must specify pathname the first time you call the Dir function, or an error occurs. If you also specify file attributes, pathname must be included. Dir returns the first file name that matches pathname. To get any additional file names that match pathname, call Dir again with no arguments."
So not
, but
, where
Watch out for the last path separator (marked in red).
Then
Ok, but remember, that (from contextual help of vba) "The ChDir statement changes the default directory but not the default drive. For example, if the default drive is C, the following statement changes the default directory on drive D, but C remains the default drive: ChDir 'D:\TMP' ".
For possible disk change use "ChDrive" statement.
Then, not:
, but better
Then, you have
???
Ad A. Ok - you copy the sheet to the new workbook as the last sheet.
Ad B.
Why in this way ? After copying your tab "Grocery" has just become the last tab in the new workbook, so is enough:
Ad C.
Ok - I understand that the "Grocery" sheet is not the last sheet of "wbOpen" workbook, but ...
Ad D. ... but why are you changing the name of the sheet if you do not save changes later ?
Bookmarks