Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Saving Excel 2003 Workbook in Excel 07 - Error Msg on Script obj | Excel Discussion (Misc queries) | |||
Update a workbook from a script | Excel Discussion (Misc queries) | |||
can share vba script using different workbook? | Excel Programming | |||
Excel 2000/XP script to Excel97 script | Excel Programming | |||
keeping VBA script with a workbook | Excel Programming |