D
Dileep Chandran
Hello Masters,
I was just trying to open all excel files (one by one) listed in
sheet8 and unprotect each by using sendkeys.
I have pasted my code below, but it doesnt seems to do the function.
Can somebody tell me whats wrong?
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As
String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Public arlinks
Public compvar As String
Public filename1 As String
Sub consolidate()
'GetFileNames
If Sheet8.Range("A2").Value <> "" Then
Selection.End(xlDown).Select
tocell = ActiveCell.Row
For i = 2 To tocell
Focus = "A" & i
Sheet8.Activate
filename1 = Range(Focus).Value
Range(Focus).Select
Focus = "A" & ActiveCell.Row
Range(Focus).Value = filename1
Workbooks.Open Filename:=filename1
Application.SendKeys "%{F11}"
Application.SendKeys "%te"
Application.SendKeys "password"
Application.SendKeys "~"
Application.SendKeys "+{TAB}"
Application.SendKeys "{RIGHT}"
Application.SendKeys "{TAB}"
Application.SendKeys " "
Application.SendKeys "{TAB}"
Application.SendKeys "{DEL}"
Application.SendKeys "{TAB}"
Application.SendKeys "{DEL}"
Application.SendKeys "~"
Application.SendKeys "%Q"
test = StrReverse(filename1)
filename1 = StrReverse(Mid(test, 1, InStr(1, test, "\") - 1))
workbooks(filename1).save
workbooks(filename1).close
Next
Else
MsgBox "No Files in the Folder"
End If
Application.CutCopyMode = False
Range("A3").Select
Sheet1.Activate
Range("A1").Select
Sheet2.Activate
Range("A1").Select
Sheet8.Activate
Range("A1").Select
MsgBox "Data Consolidated"
End Sub
Thanks
DC
I was just trying to open all excel files (one by one) listed in
sheet8 and unprotect each by using sendkeys.
I have pasted my code below, but it doesnt seems to do the function.
Can somebody tell me whats wrong?
Declare Function SHGetPathFromIDList Lib "shell32.dll" _
Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As
String) As Long
Declare Function SHBrowseForFolder Lib "shell32.dll" _
Alias "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long
Public Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type
Public arlinks
Public compvar As String
Public filename1 As String
Sub consolidate()
'GetFileNames
If Sheet8.Range("A2").Value <> "" Then
Selection.End(xlDown).Select
tocell = ActiveCell.Row
For i = 2 To tocell
Focus = "A" & i
Sheet8.Activate
filename1 = Range(Focus).Value
Range(Focus).Select
Focus = "A" & ActiveCell.Row
Range(Focus).Value = filename1
Workbooks.Open Filename:=filename1
Application.SendKeys "%{F11}"
Application.SendKeys "%te"
Application.SendKeys "password"
Application.SendKeys "~"
Application.SendKeys "+{TAB}"
Application.SendKeys "{RIGHT}"
Application.SendKeys "{TAB}"
Application.SendKeys " "
Application.SendKeys "{TAB}"
Application.SendKeys "{DEL}"
Application.SendKeys "{TAB}"
Application.SendKeys "{DEL}"
Application.SendKeys "~"
Application.SendKeys "%Q"
test = StrReverse(filename1)
filename1 = StrReverse(Mid(test, 1, InStr(1, test, "\") - 1))
workbooks(filename1).save
workbooks(filename1).close
Next
Else
MsgBox "No Files in the Folder"
End If
Application.CutCopyMode = False
Range("A3").Select
Sheet1.Activate
Range("A1").Select
Sheet2.Activate
Range("A1").Select
Sheet8.Activate
Range("A1").Select
MsgBox "Data Consolidated"
End Sub
Thanks
DC