userform u arka planda nasıl çalıştırırım?

Katılım
13 Mayıs 2005
Mesajlar
35
merhabalar
bir sıkıntım var yardımcı olursanız çok sevineceğim

userformum çalışıyor
commandbutton a tıklayınca daha önceden kayıtlı bir sayfayı çalıştırmasını istiyorum
çalıştırıyor
ama aynı zamanda userform da açık olduğu için açılan excel dosyası üzerinde işlem yapamıyorum.

Yapmak istediğim: form çalışıyorken açtığım sayfa üzerinde işlem yapmak yani sayfa açılınca userform arka planda çalışsın

böyle birşey mümkün mü? mümkünse nasıl?
 

isfa5878

Banned
Katılım
15 Kasım 2007
Mesajlar
117
Excel Vers. ve Dili
excel 2003
merhaba

1 . yol = formu açan kodu şöyle düzenleyiniz.

userform1.show 0
veya
içindeki veriler kaybolmadan gizlensin
userform1.hide

2 . yol = userform un properties inden ShowModal False yapılır.
 
Son düzenleme:
Katılım
13 Mayıs 2005
Mesajlar
35
Dostum olay olmasına oldu da, şimdi de userformu minimize etme kodu lazım. bu şekildeyken sayfayı kullanabiliyorum ama ön planda userformlar oluyor
 
Katılım
13 Mayıs 2005
Mesajlar
35
Private Declare Function FindWindowA Lib "User32" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function EnableWindow Lib "User32" _
(ByVal hWnd As Long, ByVal bEnable As Long) As Long
Private Declare Function GetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLongA Lib "User32" _
(ByVal hWnd As Long, ByVal nIndex As Long, _
ByVal dwNewLong As Long) As Long

Private Sub UserForm_Activate()
EnableWindow FindWindowA("XLMAIN", Application.Caption), 1
End Sub

Private Sub UserForm_Initialize()
Dim hWnd As Long
hWnd = FindWindowA(vbNullString, Me.Caption)
SetWindowLongA hWnd, -16, GetWindowLongA(hWnd, -16) Or &H20000
End Sub


bu kod doğruysa sanırım buldum
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
doğrumuymuş, nereye yazılyormuş.
 

isfa5878

Banned
Katılım
15 Kasım 2007
Mesajlar
117
Excel Vers. ve Dili
excel 2003
USERFORM U hem MİNİMİZE tam ekran YAPMAK userform un kod bölümüne...

Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetActiveWindow Lib "user32.dll" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hWnd As Long) As Long
Private Const SWP_NOMOVE = &H2
Private Const SWP_NOSIZE = &H1
Private Const GWL_EXSTYLE = (-20)
Private Const HWND_TOP = 0
Private Const SWP_NOACTIVATE = &H10
Private Const SWP_HIDEWINDOW = &H80
Private Const SWP_SHOWWINDOW = &H40
Private Const WS_EX_APPWINDOW = &H40000
Private Const GWL_STYLE = (-16)
Private Const WS_MINIMIZEBOX = &H20000
Private Const SWP_FRAMECHANGED = &H20
Private Const WM_SETICON = &H80
Private Const ICON_SMALL = 0&
Private Const ICON_BIG = 1&


Private Sub UserForm_Activate()
Dim hWnd As Long
hWnd = FindWindow(vbNullString, Me.Caption)
SetWindowLong hWnd, -16, GetWindowLong(hWnd, -16) Or &H10000 _
Or &H20000 Or &H40000
AddIcon ‘ image(herhalde ben silip kullandım) YOKSA SİLİNİR-------------------------------------------

AddMinimiseButton
AppTasklist Me
End Sub




‘İmage varsa eklenir((herhalde ben silip kullandım) Private Sub AddIcon()) yoksa iptal edilir
‘----------------------------------------------------------------------------------------------
Private Sub AddIcon()
Dim hWnd As Long
Dim lngRet As Long
Dim hIcon As Long
hIcon = S3.Image1.Picture.Handle
hWnd = FindWindow(vbNullString, Me.Caption)
lngRet = SendMessage(hWnd, WM_SETICON, ICON_SMALL, ByVal hIcon)
lngRet = SendMessage(hWnd, WM_SETICON, ICON_BIG, ByVal hIcon)
lngRet = DrawMenuBar(hWnd)
End Sub


‘………………………………………………………………………………………………………………………………………….


Private Sub AddMinimiseButton()
Dim hWnd As Long
hWnd = GetActiveWindow
Call SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE) Or WS_MINIMIZEBOX)
Call SetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED Or SWP_NOMOVE Or SWP_NOSIZE)
End Sub
Private Sub AppTasklist(myForm)
Dim WStyle As Long
Dim Result As Long
Dim hWnd As Long
hWnd = FindWindow(vbNullString, myForm.Caption)
WStyle = GetWindowLong(hWnd, GWL_EXSTYLE)
WStyle = WStyle Or WS_EX_APPWINDOW
Result = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_HIDEWINDOW)
Result = SetWindowLong(hWnd, GWL_EXSTYLE, WStyle)
Result = SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE Or SWP_NOACTIVATE Or SWP_SHOWWINDOW)
End Sub
 
Katılım
2 Mart 2005
Mesajlar
2,960
Excel Vers. ve Dili
ev: Ofis 2007- Win Xp
iş: Ofis 2010- Win Vista
teşekkürler hocam
 
Üst