Advertisement

02.21.2008 at 04:50AM PST, ID: 23180882
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

vbscript to check if a Sheet exists in an Excel workbook...

Tags: vbscript
Hi All,
I have a vbscript which adds data to different sheets in 1 workbook. I works great, the code is below.
The problem is that when there is new data which needs a new sheet ( anApp.AppName )  it doesn't create a new sheet. I managed to create a function which adds the sheet (also below), but it doesn't a check if the sheet already exists.
Now i need to create a built-in check whick looks for the particular sheet and if it isn't there it should call the function "ExcelAddSheet". I am stuck here.

If any could supply me with a working code  then i am very gratefull....
Cheers
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
'Add data to Excel file
'================================================================================================
 
		strExcelPath = "C:\Test.xls"
		Set objExcel = CreateObject("Excel.Application")
		Const xlUp = -4162
		Set objWB = objExcel.Workbooks.Open(strExcelPath, False, False)
		objExcel.Visible = True
 
            'Loop through all application in farm 
            For Each anApp In theFarm.Applications
 
                if Err.Number <> 0 Then
                    WScript.Echo "Can't enumerate applications"
                    WScript.Echo "(" & Err.Number & ") " & Err.Description
                    WScript.Echo ""
                    WScript.Quit Err.Number
                End if 
 
                anApp.LoadData(TRUE)
				
				
				
'				Set objwsheet = ExcelAddSheet(anApp.AppName)
				Set objWS = objWB.Sheets(anApp.AppName)
		
 
				intNextRow = objWS.Cells(65536, "A").End(xlUp).Row + 1
				objWS.Cells(intNextRow, "A").Value = anApp.AppName
				objWS.Cells(intNextRow, "B").Value = anApp.Sessions.Count
                objWS.Cells(intNextRow, "C").Value = DatePart("h", Now) & ":" & DatePart("n", Now)
                objWS.Cells(intNextRow, "D").Value = DatePart("d", Now)
				objWS.Cells(intNextRow, "E").Value = DatePart("m", Now)
                objWS.Cells(intNextRow, "F").Value = DatePart("yyyy", Now)
				objWS.Cells(intNextRow, "G").Value = Date()
				
				Next     
 
		objWB.Save
		objWB.Close
		objExcel.Quit
		Set objWS = Nothing
		Set objWB = Nothing
		Set objExcel = Nothing
 
 
'Functions
'=======================================================================
 
Function ExcelAddSheet(Name)
Set ws = objwb.Sheets.Add
ws.Name = Name
Set ExcelAddSheet = ws
End Function
Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: Schurink
Solution Provided By: webtubbs
Participating Experts: 3
Solution Grade: A
Views: 221
Translate:
Loading Advertisement...
02.21.2008 at 05:05AM PST, ID: 20947252

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.21.2008 at 05:07AM PST, ID: 20947278

Rank: Genius

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.21.2008 at 05:11AM PST, ID: 20947309

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.21.2008 at 07:11AM PST, ID: 20948377

All comments and solutions are available to Premium Service Members only.

Start your 7-day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
20080236-EE-VQP-29 / EE_QW_2_20070628