My userform is opening in the wrong window but only if I call a certain sub in my main sub.
On userform
Main sub
iInstallAddin
Any ideas?
On userform
VBA Code:
Private Sub UserForm_Initialize()
'PURPOSE: Position userform to center of Excel Window (important for dual monitor compatibility)
'SOURCE: www.TheSpreadsheetGuru.com/the-code-vault
'Start Userform Centered inside Excel Screen (for dual monitors)
Me.StartUpPosition = 0
Me.Left = Application.Left + (0.5 * Application.Width) - (0.5 * Me.Width)
Me.Top = Application.Top + (0.5 * Application.Height) - (0.5 * Me.Height)
End Sub
Main sub
VBA Code:
Sub Python_Run2()
Application.Run "iInstallAddin" ' if I remvove this call the userform opens centered
Dim passwd, pye, pys As String
Dim windowStyle As Integer
Dim waitOnReturn As Boolean
Dim objShell As Object
Run ("Python_Cfg.xlam!Python_Cfg")
passwd = Workbooks("Python_Cfg.xlam").pass
pye = Workbooks("Python_Cfg.xlam").PythonExe
windowStyle = Workbooks("Python_Cfg.xlam").windowStyle
waitOnReturn = Workbooks("Python_Cfg.xlam").waitOnReturn
Set objShell = Workbooks("Python_Cfg.xlam").objShell
pys = "H:\jadamec\Python\vba_test.py"
objShell.Run pye & " " & pys & " " & passwd, windowStyle, waitOnReturn
End Sub
iInstallAddin
VBA Code:
Sub iInstallAddin()
On Error Resume Next
AddIns("Python_Cfg").Installed = False
AddIns.Add fileName:="G:\Production\shared\Excel\VBA\vba\Python_Cfg.xlam", copyfile:=False
AddIns("Python_Cfg").Installed = True
End Sub
Any ideas?