|
-
Jun 19th, 2000, 07:44 PM
#1
Thread Starter
New Member
I want to use the BrowseFolder tool like the one on this site in VBA for Word in order to pick a directory where a lot of scripts are located.
These scripts will be placed in the Word document that's currently open.
When I import the code from this tool into the VBE for Word, it nag's about a compile error: hWnd
This handle is the first argument to be parsed to the module which browses for the directory.
In VB 6.0 it works, in VBA for Word it won't.
Who can help me?
-
Jun 20th, 2000, 02:09 PM
#2
Lively Member
Just fount out...
Here is a code to get the handle to both the Window and the control.
Code:
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hwndParent As Long, ByVal hwndChildAfter As Long, ByVal lpszClass As Any, ByVal lpszWindow As Any) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Private Sub GetHwnd()
Dim hwnd As Long
Dim hWndCommandButton As Long
hwnd = FindWindow(CLng(0), CStr(ActiveDocument.Parent.Caption))
If hwnd <> 0 Then
hWndCommandButton = FindWindowEx(hwnd, 0, CLng(0), "BUTTON_CAPTION_GOES_HERE")
End If
End Sub
-
Jun 20th, 2000, 03:32 PM
#3
Thread Starter
New Member
I implemented the code you replied in the form in which the button is placed.
Now VBA complains about the ByRef argumenttypes which do not agree.
what is the error? If you want i can zip the code to you!
thanks anyway so far!
-
Jun 20th, 2000, 05:11 PM
#4
Lively Member
Where does it complain? The code is pretty simple.
If it complains about byrefs and byvals try switching the byrefs with byvals.
The code below was tested in Word97 and had no problems.
Code:
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As Any, ByVal lpWindowName As Any) As Long
Function GetHwnd() As Long
GetHwnd = FindWindow(CLng(0), CStr(ActiveDocument.Parent.Caption))
End Function
Sub Test()
MsgBox GetHwnd
End Sub
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
|