Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the following Code that that works great under Office XP/2003
versions except one problem PC that uses Office XP and Windows 2000. I have a Reference set to Microsoft VBA Extensibility v 5.3. Is there an issue with running code via VBA to insert Code into ThisWorkbook under Win2000? 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 Sub Populate_TW_2() 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 msg1 = "Worksheets(""View"").Visible = True" & vbCr & _ "Dim sh As Worksheet" & vbCr & _ "For Each ws In Worksheets " & vbCr & _ "If ws.Name = ""View"" Then" msg2 = "ws.Visible = True" & vbCr & _ "Else" & vbCr & _ "ws.Visible = xlVeryHidden" & vbCr & _ "End If" & vbCr & _ "Next" With ActiveWorkbook.VBProject.VBComponents("ThisWorkboo k").CodeModule StartLine = .CreateEventProc("BeforeClose", "Workbook") + 1 ..InsertLines StartLine, msg1 & vbCr & msg2 End With Application.VBE.MainWindow.Visible = False ErrH: LockWindowUpdate 0& End Sub |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Worked it out as per http://www.cpearson.com/excel/vbe.htm
I hadn't changed the "Trusted Sources" tab, and put a check next to the "Trust access to Visual Basic Project". Sean wrote: I have the following Code that that works great under Office XP/2003 versions except one problem PC that uses Office XP and Windows 2000. I have a Reference set to Microsoft VBA Extensibility v 5.3. Is there an issue with running code via VBA to insert Code into ThisWorkbook under Win2000? 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 Sub Populate_TW_2() 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 msg1 = "Worksheets(""View"").Visible = True" & vbCr & _ "Dim sh As Worksheet" & vbCr & _ "For Each ws In Worksheets " & vbCr & _ "If ws.Name = ""View"" Then" msg2 = "ws.Visible = True" & vbCr & _ "Else" & vbCr & _ "ws.Visible = xlVeryHidden" & vbCr & _ "End If" & vbCr & _ "Next" With ActiveWorkbook.VBProject.VBComponents("ThisWorkboo k").CodeModule StartLine = .CreateEventProc("BeforeClose", "Workbook") + 1 .InsertLines StartLine, msg1 & vbCr & msg2 End With Application.VBE.MainWindow.Visible = False ErrH: LockWindowUpdate 0& End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Populate ThisWorkbook via Code | Excel Programming | |||
inserting code into code module crashes | Excel Programming | |||
Deleting Code in 'ThisWorkbook' | Excel Programming | |||
Importing Code into 'ThisWorkbook' | Excel Programming | |||
Delete the code in ThisWorkbook | Excel Programming |