Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


Adding an Excel Macro via VBScript

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,27781
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Adding an Excel Macro via VBScript
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 Adding an Excel Macro via VBScript - 11/6/2005 3:41:11 AM   
  swinston

 

Posts: 4
Score: 0
Joined: 11/6/2005
Status: offline
I have a vbscript that writes to an excel spread sheet.
I would like to programatically add an Excel Macro to the workbook.
Is this possible and if so how is it done?

Thanks Steve
 
 
Post #: 1
 
 RE: Adding an Excel Macro via VBScript - 11/6/2005 7:44:07 AM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
Welcome, SWinston,

If you are automating Excel thru VBScript, what is your idea with the macro then?
Is is possible for you to create a template Excel file, with a macro in it?

Call a macro from VBScript:
[code]xl.Run("<macroname>")[/code]

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to swinston)
 
 
Post #: 2
 
 RE: Adding an Excel Macro via VBScript - 11/6/2005 8:34:09 AM   
  swinston

 

Posts: 4
Score: 0
Joined: 11/6/2005
Status: offline
Thankyou for the quick response. However that is not what I am looking for.
Step 1) I have a vbscript that collects data from one database and writes it to an excel spreadsheet.
Step 2) After which the spreadsheet is handed over to a Project Manager in which he MANUALLY examines the data and then needs to turn certain cells GREEN by highlighting the cell and pressing CTRL G.
Step 3) I have another script that reads the spreadsheet looking for GREEN cells, upon finding them it uploads those into a different database.

I manually created the excel macro that is used in step 2 (see macro below) that the PM uses. I am looking for a way to create the macro via the Step 1 vbscript. The PM will still need to turn cells GREEN but the Macro makes it much easier for them. Yeah I know I could create a blank workbook with the macro already in it and use that as a template, but I was hoping for a way of doing it via vbscript.

Thanks again
Steve

Sub Green_Fill()
' Turn_IT_Green Macro
' Keyboard Shortcut: Ctrl+g
'
   With Selection.Interior
       .ColorIndex = 10
       .Pattern = xlSolid
   End With
End Sub

(in reply to Snipah)
 
 
Post #: 3
 
 RE: Adding an Excel Macro via VBScript - 11/6/2005 10:24:08 PM   
  Snipah


Posts: 1343
Score: 6
Joined: 11/1/2004
From: Netherlands
Status: offline
i see, my suggestion is still to use the template: ".XLT"

_____________________________

For more information, please see the "Read me First" topic.

http://www.visualbasicscript.com

(in reply to swinston)
 
 
Post #: 4
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> Adding an Excel Macro via VBScript Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts