-
Nov 30th, 2007, 12:42 AM
#1
Thread Starter
Addicted Member
Make exe file for excel vba code
I am using the following codes and working well with excel. How can I use this code in vb6 to make an exe file so that the same need to be installed to use the code?
In a standard module:
Code:
Public Sub Inf1()
On Error GoTo endo:
Dim cell As Range
Dim mFormat As String
For Each cell In Selection
If cell.Value > 0 Then
mFormat = "[>=10000000]#\,##\,##\,##0;[>=100000]##\,##\,##0;##,##0"
ElseIf cell.Value < 0 Then
If cell.Value >= -99999 Then
mFormat = "(#,##0);(#,##0)"
Else
mFormat = "[<=-10000000](#\,##\,##\,##0);[<=-100000](##\,##\,##0);(##,##0)"
End If
End If
If cell.Value = 0 Then
mFormat = "0;;-"
cell.HorizontalAlignment = xlRight
End If
cell.NumberFormat = mFormat
Next cell
endo:
End Sub
In another standard module:
Code:
Sub aa()
Application.OnKey "%r", "Inf1"
End Sub
In This Workbook module:
Code:
Private Sub Workbook_Open()
Dim objCmdBrPp As CommandBarPopup, oSubMenu As CommandBarPopup
' 7 - index of Data menu
' you can find Data menu by enumerating all controls
Set objCmdBrPp = Application.CommandBars("Worksheet Menu Bar").Controls(7)
Set oSubMenu = objCmdBrPp.Controls.Add(Type:=msoControlPopup, before:=objCmdBrPp.Controls.Count, temporary:=True)
Dim objCmdBtn As CommandBarButton
Set objCmdBtn = objCmdBrPp.Controls.Add(Type:=msoControlButton, temporary:=True)
With objCmdBtn
.Caption = "Indian Numbe&r Format"
.OnAction = "Inf1"
End With
Set objCmdBtn = Nothing
End Sub
-
Nov 30th, 2007, 01:27 AM
#2
Re: Make exe file for excel vba code
You should just make an xla addin for excel by using excel.
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
-
Nov 30th, 2007, 02:12 AM
#3
Thread Starter
Addicted Member
Re: Make exe file for excel vba code
yeah this I have made as an addin but I want to make it an exe file How that can be done?
-
Nov 30th, 2007, 05:43 AM
#4
Re: Make exe file for excel vba code
si the geek has a tutorial for converting vba to vb6
main thing is to make all ranges as part of the vb6 object that contains them
dim ranges, sheets or workbooks as objects
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Nov 30th, 2007, 06:16 AM
#5
Thread Starter
Addicted Member
Re: Make exe file for excel vba code
Thanks westconn1 for the reply I have searched the forum and also the posts by si the greek But couldnot find the tutorial Could you please provide the link?
-
Nov 30th, 2007, 07:26 AM
#6
Re: Make exe file for excel vba code
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
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
|