Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Running windows command from a VB code

Hi

Need help with this VB code.

What the current code does is - Picks up time from US Navy websit
http://tycho.usno.navy.mil

I would like to modify it to capture the server time (The time I get b
running the command "net time" at the command prompt in Windows).

For reference the IP address of the server can be taken to b
192.168.1.17

Thanks,
Saurabh


Sub TimeAfterTime()

With Application
.ScreenUpdating = False
.DisplayAlerts = False
.Calculation = xlCalculationManual
End With

Dim WebCopy As Object
Dim WebURL As String
Set WebCopy = Sheets("Sheet2")
WebURL = "http://tycho.usno.navy.mil/cgi-bin/timer.pl"
WebCopy.Activate
Cells.Clear

With WebCopy.QueryTables.Add(Connection:="URL;" & WebURL
Destination:=WebCopy.Range("A1"))
.BackgroundQuery = True
.TablesOnlyFromHTML = False
.Refresh BackgroundQuery:=False
.SaveData = True
End With

Range("1:2").EntireRow.Delete
Range(("A2"), Range("A2").End(xlDown)).EntireRow.Delete
With Range("A1")
.Replace What:="
", Replacement:=""
.Replace What:="UTC", Replacement:=""
.Replace What:=".", Replacement:=""
.Replace What:=", ", Replacement:=", " & Year(Now) & " "
.Value = Trim(.Value)
.NumberFormat = "mmmm d, yyyy, hh:mm:ss"
End With

Range("B1").FormulaR1C1 = "=R1C1-TIME(5,,)"
Range("B1").Value = Range("B1").Value
Columns(2).AutoFit
Columns(1).Delete Shift:=xlToLeft

With Application
.ScreenUpdating = True
.DisplayAlerts = True
.Calculation = xlCalculationAutomatic
End With

End Su

--
Message posted from http://www.ExcelForum.com

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
command code ( GOTO command) in formula calan New Users to Excel 1 June 11th 09 09:44 AM
i have two windows xp running on my pc and seem to con flict with custer Excel Discussion (Misc queries) 1 November 21st 05 09:30 PM
How to Mute/Enable Windows Sounds whilst running VBA code Hotbird[_3_] Excel Programming 0 July 29th 04 04:43 PM
How to Mute/Enable Windows Sounds whilst running VBA code Hotbird[_3_] Excel Programming 0 July 20th 04 09:34 PM
Running command button click event code Marishah Warren Excel Programming 1 December 31st 03 07:53 AM


All times are GMT +1. The time now is 08:22 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"