Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default ThisWorkbook populate with Code Q

Would anyone know what the part-code below debugs at "FindWindow" -
I'm using Excel 2007 and code worked perfectly in 2003

Sub Populate_TW()

Dim StartLine As Long
Dim msg1 As String, msg2 As String

Dim VBEHwnd As Long
On Error GoTo ErrH:
Application.VBE.MainWindow.Visible = False
VBEHwnd = FindWindow("wndclass_desked_gsk", _
Application.VBE.MainWindow.Caption)
If VBEHwnd Then
LockWindowUpdate VBEHwnd
End If
.......
........
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default ThisWorkbook populate with Code Q

That looks like some of my code. What sort of problem are you having?
Exactly what error messages do you receive? The code works fine for me
in Excel 2007.

Cordially,
Chip Pearson
Microsoft Most Valuable Professional
Excel Product Group, 1998 - 2009
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)


On Mon, 26 Jan 2009 09:31:29 -0800 (PST), Seanie
wrote:

Would anyone know what the part-code below debugs at "FindWindow" -
I'm using Excel 2007 and code worked perfectly in 2003

Sub Populate_TW()

Dim StartLine As Long
Dim msg1 As String, msg2 As String

Dim VBEHwnd As Long
On Error GoTo ErrH:
Application.VBE.MainWindow.Visible = False
VBEHwnd = FindWindow("wndclass_desked_gsk", _
Application.VBE.MainWindow.Caption)
If VBEHwnd Then
LockWindowUpdate VBEHwnd
End If
......
.......
End Sub

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default ThisWorkbook populate with Code Q

It sure is Chip, probably all of it. I have used it successfully with X
\l 2003 but since I upgraded to XL 2007 it hasn't worked. It debugs on
"FindWindow" and I don't know why as I haven't changed any of the
code. Two things I remember that were required for it to work on 2003
was Trust Access to the VBA object and a reference within VB to MS VB
extensibility. I've confirmed both are checked but I get this error
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default ThisWorkbook populate with Code Q

Is the FindWindow API declared and available in your for use in module

but why not simply

VBEHwnd = Application.VBE.MainWindow.Hwnd

Regards,
Peter T

"Seanie" wrote in message
...
Would anyone know what the part-code below debugs at "FindWindow" -
I'm using Excel 2007 and code worked perfectly in 2003

Sub Populate_TW()

Dim StartLine As Long
Dim msg1 As String, msg2 As String

Dim VBEHwnd As Long
On Error GoTo ErrH:
Application.VBE.MainWindow.Visible = False
VBEHwnd = FindWindow("wndclass_desked_gsk", _
Application.VBE.MainWindow.Caption)
If VBEHwnd Then
LockWindowUpdate VBEHwnd
End If
......
.......
End Sub



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default ThisWorkbook populate with Code Q

Below, exactly as in my 2003 workbook, which worked

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default ThisWorkbook populate with Code Q

That looks fine assuming of course you are calling the APIs from within the
same module.

You didn't answer Chip's question about what error you get.

Did you try reading directly as I suggested -

VBEHwnd = Application.VBE.MainWindow.Hwnd

(even in Excel97)

Regards,
Peter T

"Seanie" wrote in message
...
Below, exactly as in my 2003 workbook, which worked

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal ClassName As String, ByVal WindowName As String) As Long
Private Declare Function LockWindowUpdate Lib "user32" _
(ByVal hWndLock As Long) As Long



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 202
Default ThisWorkbook populate with Code Q

Yes, its within the same module.

Error I am getting is on text "findWindow" with message Sub or
Function not defined

  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default ThisWorkbook populate with Code Q

Head the module containing the APIs and the code 'Option Explicit' and do
Debug / Compile. It will probably blow in the same place.

What is your OS, 64 bit per chance (not that I could say why that should
matter)

Third time, have you tried returning the hWnd directly from MainWindow as
suggested.

Regards,
Peter T


"Seanie" wrote in message
...
Yes, its within the same module.

Error I am getting is on text "findWindow" with message Sub or
Function not defined



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Xl 2007 v 2003 Re Populate ThisWorkbook via VBA Seanie Excel Programming 2 January 24th 09 09:10 PM
Populate ThisWorkbook Q Sean Excel Programming 7 January 16th 07 05:22 PM
Populate ThisWorkbook via Code Sean Excel Programming 13 January 14th 07 06:03 PM
Remove ThisWorkbook code via VBA PCLIVE Excel Programming 3 August 8th 05 09:31 PM
Delete the code in ThisWorkbook Darrin Henry Excel Programming 1 October 1st 03 11:10 PM


All times are GMT +1. The time now is 10:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"