|
-
Apr 27th, 2004, 01:38 AM
#1
Thread Starter
Fanatic Member
making a button invisible from vb6 (resolved)
is it possible to make a button in an excel spreadseet to become invisible from vb6 after calling out the excel template?
Last edited by Goh; Apr 28th, 2004 at 12:54 PM.
-
Apr 27th, 2004, 05:39 AM
#2
Frenzied Member
-
Apr 28th, 2004, 11:30 AM
#3
Here is a small demo I made for you to see how to control the
command buttons in Excel from VB. The demo creates a new
workbook and creates a command button in Excel. Then on the
click of the vb button it will change the visibility of the Excel
command button.
VB Code:
'Add a reference to MS Excel xx.x Object Library
'Add a reference to MS Office xx.x Object Library
'Add one command button (Command1)
Option Explicit
Dim oXL As Excel.Application
Dim oWB As Excel.Workbook
Dim oSHT As Excel.Worksheet
Dim oSHP As Excel.Shape
Private Sub Command1_Click()
For Each oSHP In oSHT.Shapes
If oSHP.Type = msoOLEControlObject And oSHP.Name = "CommandButton1" Then
'Toggle the visibility property of the Excel command button on each click of the vb button
oSHP.Visible = Not oSHP.Visible
End If
Next
End Sub
Private Sub Form_Load()
Set oXL = New Excel.Application
'Add a new workbook for the demo
Set oWB = oXL.Workbooks.Add
oWB.Activate
oXL.Visible = True
Set oSHT = oWB.Worksheets("Sheet1")
'Add a command button to sheet1
oSHT.Shapes.AddOLEObject Left:=100, Top:=100, Width:=100, Height:=25, ClassType:="Forms.CommandButton.1"
End Sub
Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
'Clean up
Set oSHP = Nothing
Set oSHT = Nothing
oWB.Close False
Set oWB = Nothing
oXL.Quit
Set oXL = Nothing
End Sub
Enjoy
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 28th, 2004, 12:53 PM
#4
Thread Starter
Fanatic Member
wow! thanks alot man!
-
Apr 28th, 2004, 12:56 PM
#5
Your welcome.
Dont forget to resolve your other thread.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Apr 28th, 2004, 08:08 PM
#6
New Member
FWIW:
The button will still be visible in design mode. This is great for the developer since it's hard to change something that you can't see. However, if a user opens the file with macros disabled, the button will be there.
If this is something that you don't want then it might be better to delete the button instead of just hiding it.
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
|