LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 129
Default Stand alone VBA script files

This is how you import a standalone exported VBA Module. This imports a
module named WriteData.bas and runs a macro named WriteAsText in that
module :

Set objwb = ThisWorkbook
Set oVBC = objwb.VBProject.VBComponents
Set CM = oVBC.Import(GetPath() & "\WriteData.bas")
objwb.Application.Run "WriteAsText"

This clip shows how you add VBA code from a String using CM defined
above :

CM.CodeModule.AddFromString "Public Const TEXT_FILE = chr(34) &
"C:\file.txt" & r(34) & chr(10)

Yes, one can execute the code above from VBScript.

In the most general case, if you have a worksheet that uses only VBA
you can convert your Worksheet into a Worksheet created by a VBScript.

This VBScript code shows how you create your Excel, Workbook, and
access Worksheets:

Dim objXL,objwb,objws 'Put this at top of VBScript file for global
scope

Set objXL = CreateObject("Excel.Application")
Set objwb = objXL.Workbooks.Add
Set objws = objwb.Worksheets("Sheet1")

Sub ExcelSetUp()
objws.Name = "ActiveDirectory"
objws.Activate
objXL.Visible = True
data = Array ( "employeeID", "sAMAccountName")
objws.Range(objws.Cells(1,1),objws.Cells(1,2)).Val ue = data
End Sub





tishoo wrote:
Question: Is it possible to have a standalone VBA script file that Excel can
open, or does the VBA have to be written into an Excel document? If so how
is it done?

Ta
T


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does CSV files stand for?? TexasDude Excel Discussion (Misc queries) 4 June 18th 08 08:03 PM
Script for Multiple Files Neil Excel Discussion (Misc queries) 5 April 10th 08 10:13 PM
Stand alone VBA script files tishoo Excel Discussion (Misc queries) 6 December 29th 06 06:02 PM
Stand alone VBA script files tishoo Setting up and Configuration of Excel 6 December 29th 06 06:02 PM
converting VBA scripts to stand-alone exe files Philip[_6_] Excel Programming 2 July 22nd 04 03:01 PM


All times are GMT +1. The time now is 07:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"