VBA from notepad

Mahesh

New Member
Joined
Nov 13, 2004
Messages
21
Instead of writing a vba code from VB within excel, can I write it in notepad?

If yes, if I run that notepad file will it work exactly like I am running the code within excel?
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
You can definatly write it in notepad. Not sure if there is a way to run it. Might be able to automate importing it then executing it... Why would you want to though?
 
Upvote 0
There is nothing to stop you writing VBA in any text editor you want. However, AFAIK you will need to copy and paste it into a proper Excel module before it will work.

Are you trying to write some VB-style code that will run stand-alone (ie. without requiring Excel to be open)? If so then you might want to look up VBScript. There's a useful reference at http://www.devguru.com
 
Upvote 0
Vbscript and Excel VBA

Following is the script from AVAYA CMS CenterVu Supervisor that opens CMS, runs a report and creates an excel file in the path specified. I think this code is in VBScript. What I want is, when this code is executed It should start executing a Excel VBA Macro without any manual intervention. I don't want to stop here and then go to Excel and run the VBA separately.

The other option would be, have the below code converted into Excel VBA and then I will continue running the other VBA macro. I can't do the converting part and if I paste the below code into Excel module, I get an error Argument not optional in the line "Set Log = CreateObject("AVSERR.cvsLog")"

Code:
'LANGUAGE=ENU
'SERVERNAME=xx.xx.xx.xx
'## cvs_cmd_begin
Public Sub Main()

On Error Resume Next
    cvsSrv.Reports.ACD = 1
    Set Info = cvsSrv.Reports.Reports("Historical\CMS custom\Custom Multi/Split")
    If Info Is Nothing Then
        If cvsSrv.Interactive Then
            MsgBox "The report Historical\CMS custom\Custom Multi/Split was not found on ACD 1.", vbCritical Or vbOKOnly, "Avaya CMS Supervisor"
        Else
            Set Log = CreateObject("AVSERR.cvsLog") 
            Log.AutoLogWrite "The report Historical\CMS custom\Custom Multi/Split was not found on ACD 1."
            Set Log = Nothing
        End If
    Else
        b = cvsSrv.Reports.CreateReport(Info,Rep)
        If b Then
            Rep.SetProperty "Split(s)","71"
            Rep.SetProperty "Date","0"
            Rep.SetProperty "Times","0-12:59"
            b = Rep.ExportData("M:\Maxi\abc.xls", 9, 0, True, True, True)
            Rep.Quit
            If Not cvsSrv.Interactive Then cvsSrv.ActiveTasks.Remove Rep.TaskID
            Set Rep = Nothing
        End If
    End If
Set Info = Nothing

'## cvs_cmd_end
End Sub
[code]
 
Upvote 0
CreateObject is normally a VBScript command, but VBA gives you a different way to do a simiar thing. In Excel I think you need to add a reference to whatever this "AVSERR" thing is (presumably a DLL file or something?). Then you might be able to change the code to something like this:
Code:
Dim Log as cvsLog
...
Set Log = New cvsLog
...
Set Log = Nothing
 
Upvote 0

Forum statistics

Threads
1,215,012
Messages
6,122,682
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top