Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 42
Default Stand alone VBA script files

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


  #2   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 7,247
Default Stand alone VBA script files

You're probably confusing VBScript and VBA. Both are derivatives of Visual
Basic. VBA is always stored within a host document like an Excel workbook or
a Word document. VBScript is stored in simple text files with a 'vbs'
extension. VBScript runs outside of any application (other than the VBS
interpreter).

By the way, you need post only in one group.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"tishoo" wrote in message
...
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




  #3   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 11,058
Default Stand alone VBA script files

Use .bas files

Using Excel VBA editor, create a script, then export it to a standalone file
(.bas)
--
Gary's Student


"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



  #4   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 6,582
Default Stand alone VBA script files

Note: A .bas file cannot be run as is, but must first be imported into an
appropriate host document (like an Excel workbook).

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"Gary''s Student" wrote in message
...
Use .bas files

Using Excel VBA editor, create a script, then export it to a standalone
file
(.bas)
--
Gary's Student


"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





  #5   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 42
Default Stand alone VBA script files


"Gary''s Student" wrote

Use .bas files

Using Excel VBA editor, create a script, then export it to a standalone
file
(.bas)


Thanks for the tip. Worth noting that approach only works if the BAS file is
stored locally. It seems to be impossible to import a BAS file over the web.




  #6   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming,microsoft.public.excel.setup
external usenet poster
 
Posts: 6,582
Default Stand alone VBA script files

It's hard to email them, too. A lot of email programs and antivirus programs
block them, because we all know that any code is malicious and the user
can't be trusted to open a "safe" one.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"tishoo" wrote in message
...

"Gary''s Student" wrote

Use .bas files

Using Excel VBA editor, create a script, then export it to a standalone
file
(.bas)


Thanks for the tip. Worth noting that approach only works if the BAS file
is stored locally. It seems to be impossible to import a BAS file over the
web.



  #7   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


Reply
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
Stand alone VBA script files tishoo Excel Discussion (Misc queries) 6 December 29th 06 06:02 PM
Seemingly random .tmp files lbour New Users to Excel 3 August 14th 06 11:17 PM
VB script for converting each worksheet into individual pdf files. G Setting up and Configuration of Excel 5 November 23rd 05 03:34 AM
merging my excel files Donna YaWanna Excel Discussion (Misc queries) 1 June 14th 05 12:53 AM
Cannot access read-only documents. tomgillane Excel Discussion (Misc queries) 14 February 7th 05 10:53 PM


All times are GMT +1. The time now is 12:37 AM.

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

About Us

"It's about Microsoft Excel"