Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 101
Default Error - SendKeys in between a macro

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Worksheet Functions 1 May 3rd 08 02:35 PM
I tried to get around the problem of the pivot table field settingdefaulting to Count instead of Sum by running a macro of change the settingfrom Count to Sum. However, when I tried to run the Macro, I got error messageof run time error 1004, unable Enda80 Excel Discussion (Misc queries) 1 May 3rd 08 10:52 AM
macro doesn't properly record AutoSum (and SendKeys doesn't work) crimsonkng Excel Programming 2 November 21st 06 02:11 PM
What's the syntax error with this SendKeys code? Phil1982 Excel Programming 1 March 19th 06 06:52 PM
Slow down SendKeys macro [email protected] Excel Programming 1 August 29th 05 10:20 AM


All times are GMT +1. The time now is 04:00 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"