Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vbs -> C# organizational question 1

Status
Not open for further replies.

blpcrs

Programmer
Aug 25, 2011
19
US
I have a ton of Utility classes in vbscript, ie excelUtils would have methods such as isRowEmpty and gotoCell
Code:
Public Sub isRowEmpty (byval iRow)
	Dim xlObj : set xlObj = eval("getobject(,""Excel.Application"")")		
	Dim actWS : Set actWS = xlObj.ActiveWorkbook.ActiveSheet

	cell = "A" & iRow
	actWS.range(cell).Activate
	isRowEmpty = false
	If xlObj.CountA(xlobj.ActiveCell.EntireRow)=0 Then isRowEmpty = true
		
	set actWS = nothing	
	set xlObj = nothing
End Sub 

Public Sub gotoCell (byval setCell)
	Dim xlObj
	Dim actWS	
	Set xlObj = eval("getobject(,""Excel.Application"")")		
	Set actWS = xlObj.ActiveWorkbook.ActiveSheet

	actWS.range(setCell).Activate
	set actWS = nothing
	set xlObj = nothing
End Sub
Similar things for getting getting and setting regKeys, get IP address, etc.
Working on creating a new framework in C#. Experts, does it make sense to carry forward these sort of classes, or just call it straight, ie use Microsoft.Office.Interop.Excel methods directly where applicable? thanks in advance!
 
Stick it in a class. Is it just Excel you are handling or do you have to do word as well?

Note that if you are using COM as the VBScript is, you musn't touch the keyboard or change the focus while the code is running. Also, you will see the cursor moving all over the ribbon - this cannot be switched off, even if the ribbon is minimized.
 
Yes, word and ppt will get included in the libraries as well. guessing a namespace of officeProducts,and a class for each product would suffice. Thanks for the heads up on the focus and cursor movement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top