Sub POSht()
'Dim wbkTo As Workbook
Dim wbkFrom As Workbook
Dim TheFile As Variant
Dim FName As String
'
With Workbooks("Fix POsht.xls")
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module5").Export FName
End With
NewFN = Application.GetOpenFilename(FileFilter:="Excel Files (*.xls), *.xls", Title:="Please select a file")
If NewFN = False Then
' They pressed Cancel
MsgBox "You did not select a file"
Exit Sub
Else
Workbooks.Open Filename:=NewFN, UpdateLinks:=0
End If
With Application
'Go to the VBE
.SendKeys "%{F11}", True
'Activate Project Explorer window
.SendKeys "^r", True
'Tab your way to the workbook project
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
.SendKeys "{TAB}", True
'
'Simulate the Enter key
.SendKeys "~", True
'
' - delay 1 second
Application.Wait Now + TimeValue("00:00:01")
'Enter your password - - this example is "Password"
.SendKeys "password123"
'Enter again
.SendKeys "~", True
End With
ActiveWorkbook.VBProject.VBComponents.Import NewFN
End Sub
Bookmarks