LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Add userform to excel workbook using script

I am able to add code modules to excel, creating Excel macros via VBScript.
Is it possible to add Excel Userforms the same way? Here is my code below:

Dim Code, objXL, Workbook, Worksheet, Macros dim oFSO, oFile,f
Const ForReading = 1, ForWriting = 2, ForAppending = 8

Set fso = CreateObject("Scripting.FileSystemObject")


Set f = fso.OpenTextFile("c:\KFA\Book1.txt", ForReading) 'Read the text file
Code = f.Read(1500)'1500 denotes the number of characters
Set objXL = CreateObject("Excel.Application")
Set Workbook = objXL.Workbooks.Open("C:\KFA\BOOK1.XLS")
Set Worksheet = Workbook.Sheets(1)
'Add ref to macro position
Set Macros = Workbook.VBProject.VBComponents(1).CodeModule
'Add new macro; AddFromFile is also an option

Macros.AddFromString Code





' Save the result
objXL.Save
Set objXL = Nothing

 
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
Saving Excel 2003 Workbook in Excel 07 - Error Msg on Script obj WL Excel Discussion (Misc queries) 0 January 15th 08 06:20 PM
Update a workbook from a script [email protected] Excel Discussion (Misc queries) 1 March 8th 06 02:30 PM
can share vba script using different workbook? tango Excel Programming 0 November 7th 04 11:47 PM
Excel 2000/XP script to Excel97 script hat Excel Programming 3 March 2nd 04 03:56 PM
keeping VBA script with a workbook Steve Excel Programming 2 January 27th 04 04:01 PM


All times are GMT +1. The time now is 12:36 PM.

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"