Results 1 to 1 of 1

using one wb macro to open another wb VBAproject password

Threaded View

  1. #1
    Registered User
    Join Date
    03-09-2007
    Posts
    75

    using one wb macro to open another wb VBAproject password

    Hi,

    I need some advice here. I am currently using a file to change the macro that had already been sent out to various users.

    In the file, the macro is set to replace amended module 5 with those files that are already sent out (debugging). But I do not want to give users my VBAProject password, just in case they mess up the macro.

    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
    But the problem is that it never seems to be able to activate the newly opened file VBA project and thus, it never been able to write the password into the password window. This will prevent me from replacing the module 5 as the VBAProject is still protected.

    I am finding that some recommendation for using sendkeys are rather restrictive cos we need to first identify (hard-coding it) which position the destination file are locted in the project window.

    Any help is greatly appreciated.

    Thanks,
    CL
    Last edited by clng; 02-08-2009 at 09:44 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1