This may not be the proper forum to ask, so I'll apologize up front, but I am hoping someone may be able to help. I have the following code extracted from a large VBScript. What I'm trying to do is add into this, a macro that was created in an excel sheet, but I am not even sure it can be done.
Excel Macro
Code:
Sub SaveAsExcel(strFileName) Const xlnormal = -4143
Const xlAscending = 1
Const xlDescending = 2
Const xlYes = 1
const xlSortValues = 1
Dim oXL, objRange, objRange2
If Not fso.FileExists(strFileName) Then WScript.Quit
On Error Resume Next
Set oXL = CreateObject("Excel.Application")
If Err <> 0 Then 'Excel not installed
Err.Clear
On Error GoTo 0
Exit Sub
End If
oXL.DisplayAlerts=False ' don't display overwrite prompt.
oXL.Workbooks.Open(strFileName)
Set objRange = oXL.Worksheets(1).UsedRange
Set objRange2 = oXL.Range("A2")
objRange.Sort objRange2, xlAscending,,,,,, xlYes
objRange.EntireColumn.Autofit()
Dim oWS
Set oWS = oXL.Worksheets(1)
oWS.Activate
oXL.ActiveWorkBook.SaveAs strFileName,xlnormal,,,,,,,True 'overwrite existing
oXL.ActiveWorkBook.close
OXL.Quit
End Sub
Excel Macro
Code:
Sub Macro1() Columns("F:F").Select
Selection.Insert Shift:=xlToRight, CopyOrigin:=xlFormatFromLeftOrAbove
Range("F1").Select
ActiveCell.FormulaR1C1 = "Domain"
Range("F2").Select
Application.CutCopyMode = False
ActiveCell.FormulaR1C1 = "=MID(RC[-1],4,3)"
Selection.AutoFill Destination:=Range("F2:F400"), Type:=xlFillDefault
Range("F2:F400").Select
End Sub