Is it possible? Fetch data from password form protected workbook.

PeaceCheese

New Member
Joined
Aug 28, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
I have an excel workbook which has a sign in form. The sign in form has fields for “Purpose of visit” (dropdown selection), “date“, “username” and “password”. (For reference, I will call this workbook 1) When you sign into this workbook it launches another form where the user does all of their work/data entry.

I would like to use VBA from a different workbook (workbook 2) to get data from sheets in workbook 1.

Is there a way to do that in the background with VBA?

The code I have right now causes the workbook 1 sign in form to launch. If I sign into it then the work form will launch. I have to close that form then the data gets transferred.

I want everything to take place in the background. Is that possible?

Thanks in advance for any help with this.

VBA Code:
Private Sub cmd_pull_prev_report_Click()


Application.ScreenUpdating = False
Sheets("CPs").Visible = xlSheetVisible

Sheets("CPs").Activate
Rows("2:" & Rows.Count).ClearContents


    Dim filepath As String
    Dim sourceWb As Workbook
    Dim TargetWb As Workbook
    
    Dim rng As Range
    Dim getaddressforpreviousfile As Range
    
    Set TargetWb = ActiveWorkbook
    
    Set rng = Sheets("Fac").Columns("B:B")
    Set getaddressforpreviousfile = rng.find(What:=Fac_Code_For_Report, LookIn:=xlFormulas, LookAt:=xlWhole, MatchCase:=False)

    filepath = UserRootURL & getaddressforpreviousfile.Offset(0, 25).Value
    
    Set sourceWb = Workbooks.Open(filepath)

    sourceWb.Sheets("CPs").Range("A2:T20").Copy Destination:=TargetWb.Sheets("CPs").Range("A2:T20")
    
    sourceWb.Close

Application.ScreenUpdating = True

End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,855
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
What starts the login form? Probably workbookopen.

Try to disable events before opening the workbook 1.
VBA Code:
Application.enableevents =False
If this doesn't work you may try:
VBA Code:
Application.AutomationSecurity = msoAutomationSecurityForceDisable
This should disable all macros in newly opened files
 
Solution

PeaceCheese

New Member
Joined
Aug 28, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
What starts the login form? Probably workbookopen.

Try to disable events before opening the workbook 1.
VBA Code:
Application.enableevents =False
If this doesn't work you may try:
VBA Code:
Application.AutomationSecurity = msoAutomationSecurityForceDisable
This should disable all macros in newly opened files

Brilliant! Fricken Amazing!

I put Application.enableevents =False right before my open statement and it fetched the info and I never got the sign in prompt for Workbook 1.

Didn't try the second suggestion - first is working so why would I? LOL

I can't thank you enough.
 

bobsan42

Well-known Member
Joined
Jul 14, 2010
Messages
1,855
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2013
Platform
  1. Windows
Don't forget to reset it back to TRUE.
 

Forum statistics

Threads
1,147,571
Messages
5,741,895
Members
423,693
Latest member
Excelquestion35

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top