Userform User/password runs a macro

underkar

New Member
Joined
Oct 10, 2017
Messages
1
Hi all,
I have a macro that retrieves data from AS400 (ISeries) and it saves in an excel format file. The point is that to run the retrieve it is mandatory to enter en username and a passaword. My macro works when there is just one user, because I declare I enter both variables in the code. But i want to share my macro with different users, so what I want to do is to create an Userform button to enter the credentials. Can anyone please show me how to relate an userform to my code?

Thank you very much!!!

Code:
Dim mysystem As New cwbx.AS400System 'Se declara el sistema al que llamará la macro
Dim bajararchivo As New cwbx.DatabaseDownloadRequest 'Se declara el objeto bajararchivo como petición de descaga
 
'Comienzo la subrutina
Sub bajararchivoAS400()
Set bajararchivo = New cwbx.DatabaseDownloadRequest
'Se definen los datos de la máquina
mysystem.Define "SINSCEE.DQB.COM"
mysystem.UserId = "Usuario"
mysystem.Password = "Contraseña"
 
Set bajararchivo.system = mysystem
bajararchivo.AS400File = "LP.LGF/GOAR" 'nombre del archivo
bajararchivo.pcFile = "C:\Users\rgumdrr\Desktop\MacroISeries\MastroArticulos\MaestroArticulos.xls" 'ruta donde bajar
bajararchivo.pcFile.FileType = cwbdtBIFF8 'tipo de archivo
bajararchivo.Download 'ejecuto la descarga
 
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
I'm new to AS400 and have only played with the VBA module for the last month. Try this.

Code:
UserForm.show
mysystem.UserId = UserForm.LoginTextBox.Value
mysystem.Password = UserForm.PasswordTextBox.Value

Within your UserForm;

Code:
Private Sub CommandButton_Click()


UserForm.hide




End Sub
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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
Back
Top