|
-
Oct 29th, 2003, 07:09 PM
#1
Thread Starter
Addicted Member
Win32 Api *resolved- code i used inside*
i was wondering if you can use win32 api or user32 api in VBA i cant seem to get some things to work that i was trying to do and it made me think, does VBA allow the use of API. well thanks for the help
Last edited by big_k105; Oct 30th, 2003 at 05:10 PM.
-
Oct 29th, 2003, 07:25 PM
#2
Fanatic Member
Yep. You can use API in VBA. Same as VB. The VBA Forms 2.0 controls don't have window handles though, so APIs won't always wok if you are trying to manipulate controls on a UserForm.
-
Oct 29th, 2003, 07:36 PM
#3
Thread Starter
Addicted Member
im trying to use sendmessage to a textbox on a worksheet do you think that should work.
VB Code:
Option Explicit
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 Const EM_SETTABSTOPS = &HCB
'in a different sub
Dim tabstop As Long
tabstop = 8
SendMessage Sheets("ECNFile").txtbox1.hwnd, EM_SETTABSTOPS, 1, tabstop
this is te code that im using the SendMessage line gets an error i cant remember what the error is off hand but i will check when i get back to work tomorrow.
thanks for the help workhorse
-
Oct 29th, 2003, 08:13 PM
#4
Fanatic Member
I would expect you get "Object doesn't support this method" because txtbox1 doesn't have an hWnd. No window handles for Forms 2.0 controls. Don't ask me why. If you map all hWnds, you will find that you get down to a container with the controls, but no hWnds for the controls inside the container. Without an hWnd, I know of no way to SendMessage (or any other API that requires an hWnd) to a Forms 2.0 control. It's not for a lack of trying. If you find way, post it!
-
Oct 30th, 2003, 09:16 AM
#5
Thread Starter
Addicted Member
well i cant seem to get it to work either. i will keep trying but i was wondering if you knew of a different way to set tab stops for a textbox in the worksheets thanks dude
-
Oct 30th, 2003, 05:09 PM
#6
Thread Starter
Addicted Member
well i got it to do what i wanted and here is the source code
VB Code:
Do While True
lngEnterPos1 = InStr(intStart, Sheets("ECNFile").txtbox1.Text, Chr(13) & Chr(10))
If (lngEnterPos1 > lngTabPos) Then
lngEnterPos1 = lngEnterPos2
Exit Do
End If
lngEnterPos2 = lngEnterPos1
intStart = lngEnterPos1 + 1
Loop
curpos1 = lngTabPos - (lngEnterPos1 + 2)
thanks for your help workhorse
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|