Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

VB editor

17 views
Skip to first unread message

Tony WONG

unread,
Nov 2, 2005, 8:31:07 PM11/2/05
to
I find the VB editor in office is very useful.

Can i call it in XP environment (not in office)?

Because i just do some scripts in FSO or Shell?

Thanks a lot.

tony


Marty List

unread,
Nov 3, 2005, 8:03:29 AM11/3/05
to

"Tony WONG" <x...@hknet.com> wrote in message
news:%23918zYB...@TK2MSFTNGP12.phx.gbl...


This isn't exactly what you're asking for, but try the "Microsoft Script
Editor". Search your drives for MSE7.EXE, and then create a shortcut to it.
If you don't have Office installed, then it probably won't be there.

With Office 2003 (v11), it's usually installed here:
"C:\Program Files\Microsoft Office\Office11\MSE7.EXE"

Miyahn

unread,
Nov 4, 2005, 7:16:21 AM11/4/05
to
"Tony WONG" wrote in message news:#918zYB4...@TK2MSFTNGP12.phx.gbl

> I find the VB editor in office is very useful.
>
> Can i call it in XP environment (not in office)?
>
> Because i just do some scripts in FSO or Shell?

I use the following script to invoke Office's VBE with some
references.(but in invisible excel)
If you run the script without parameter, the script registers
itself to the context menu of *.vbs file.

To use this script on Excel2002 or later, you must change
the macro security option.

' FileName : VBSEdit.vbs
Option Explicit
Dim Args, xlApp, iFile, Buf, FS, oFile
Set Args = WScript.Arguments
If Args.Count = 0 Then Reg_UnReg ' Set/Reset Context Menu
If Args.Count <> 1 Then WScript.Quit
If LCase(Right(Args(0), 4)) <> ".vbs" Then WScript.Quit
Set xlApp = CreateObject("Excel.Application")
xlApp.Workbooks.Add().ActiveSheet.Name = "Dummy"
With xlApp.VBE
On Error Resume Next
With .ActiveVBProject.References
'Reference for Scripting Runtime
.AddFromGuid "{420B2830-E718-11CF-893D-00A0C9054228}", 0, 0
'Reference for Shell Controls And Automation
.AddFromGuid "{50A7E9B0-70EF-11D1-B75A-00A0C90564FE}", 0, 0
'Reference for VBScript Regular Expressions
.AddFromGuid "{3F4DACA7-160D-11D2-A8E9-00104B365C9F}", 0, 0
'Reference for WMI Scripting
.AddFromGuid "{565783C6-CB41-11D1-8B02-00600806D9B6}", 0, 0
'Reference for Windows Script Host
.AddFromGuid "{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}", 0, 0
'Reference for WSHController
.AddFromGuid "{563DC060-B09A-11D2-A24D-00104BD35090}", 0, 0
End With
On Error GoTo 0
.MainWindow.Visible = True
.ActiveVBProject.VBComponents.Add 1
.CodePanes(1).Window.SetFocus
iFile = Args(0)
With .CodePanes(1).CodeModule
.DeleteLines 1, .CountOfLines: .AddFromFile iFile
End With
Do While .MainWindow.Visible: WScript.Sleep 1000: Loop
With .CodePanes(1).CodeModule
Buf = .Lines(1, .CountOfLines)
End With
End With
xlApp.ActiveWorkbook.Close False: xlApp.Quit: Set xlApp = Nothing
oFile = InputBox("Input File Name", , LongName(iFile))
If oFile = "" Then WScript.Quit
If InStr(oFile, ".") = 0 Then oFile = oFile & ".vbs"
Set FS = CreateObject("Scripting.FileSystemObject")
If FS.FileExists(oFile) Then
If MsgBox("The same name file exists. Do you overwrite it ?", _
vbYesNo) = vbNo Then Set FS = Nothing: WScript.Quit
End If
Set oFile = FS.CreateTextFile(oFile)
oFile.Write Buf: oFile.Close
'
Sub Reg_UnReg()
Const TKey = "HKCR\VBSFile\shell\EditInVBE\": Dim ENo
With CreateObject("WScript.Shell")
On Error Resume Next
.RegRead TKey: ENo = Err.Number
On Error GoTo 0
If ENo <> 0 Then
.RegWrite TKey, "Edit in VBE(&V)"
.RegWrite TKey & "Command\", _
"wscript """ & WScript.ScriptFullName & """ ""%L"""
.Popup "Registry setting added", 1
Else
.RegDelete TKey & "Command\": .RegDelete TKey
.Popup "Registry setting removed", 1
End If
End With
End Sub
Function LongName(ShortName)
With CreateObject("WScript.Shell")
With .CreateShortcut("dummy.lnk")
.TargetPath = ShortName: LongName = .TargetPath
End with
End with
End Function

--
Miyahn (Masataka Miyashita) JPN
Microsoft MVP for Microsoft Office - Excel(Jan 2005 - Dec 2005)
HQF0...@nifty.ne.jp

ljb

unread,
Nov 4, 2005, 9:07:54 AM11/4/05
to

"Miyahn" <HQF0...@nifty.ne.jp> wrote in message
news:%23D0hWlT...@TK2MSFTNGP10.phx.gbl...

This is excellent! I love it.


0 new messages