Monday, February 21, 2011

Read a Bookmark in a Word Document

Set objWord = CreateObject("Word.Application")
objword.Visible = False
Set objDoc = objWord.Documents.Open("e:\copy.doc")

Do until objDoc.AtEndofStream
                                stxt = objDoc.Readline
                                MsgBox stxt
Loop

objdoc.Close
objWord.Quit

Get Detail of Object Drive


Dim filesys
set filesys = CreateObject("Scripting.FileSystemObject")
Set drv = filesys.GetDrive("e")

select case drv.DriveType
                Case 0: drtype = "Unknown"
                Case 1: drtype = "Removable"
                Case 2: drtype = "Fixed"
                Case 3: drtype = "Network"
                Case 4: drtype = "CD-ROM"
                Case 5: drtype = "RAM Disk"
End Select

WScript.Echo "The specified drive is a " & drtype & " type disk."
WScript.Echo " "
WScript.Echo "Total size is " & drv.TotalSize & ". "
WScript.Echo "Available space is " & drv.AvailableSpace &  ". "
WScript.Echo "Type is " & drv.DriveType &  " "
WScript.Echo "Path is "  & drv.Path &  " "

Dim filesyst, drive
Set filesyst = CreateObject("Scripting.FileSystemObject")
WScript.Echo "Before Condtion"

drive =  filesyst.DriveExists("z")
WScript.Echo drive

                If filesyst.DriveExists("z") Then
                                WScript.Echo("The specified drive does exist.")
                Else
                                WScript.Echo("The specified drive does not exist.")
                End If
WScript.Echo "After Condtion"

Sort Excel Worksheet

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
Set objWorkbook = objExcel.Workbooks.Add
Set objWorksheet = objWorkbook.Worksheets(1)

objExcel.Cells(1, 1).Value = "4"
objExcel.Cells(2, 1).Value = "1"
objExcel.Cells(3, 1).Value = "2"
objExcel.Cells(4, 1).Value = "3"
objExcel.Cells(1, 2).Value = "A"
objExcel.Cells(2, 2).Value = "B"
objExcel.Cells(3, 2).Value = "C"
objExcel.Cells(4, 2).Value = "D"

Set objRange = objWorksheet.UsedRange
Set objRange2 = objExcel.Range("A1")
objRange.Sort(objRange2)
 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | JCpenney Printable Coupons