Reflections import to Excel

Robertson1995

Board Regular
Joined
Apr 1, 2009
Messages
123
I have a program called Reflections WRQ that I need to run a command and have the results dump into an Excel worksheet. I am using the below code and its working, but here's the problem I'm having. When I run the command a second time, it does not overwrite the data from the first time I ran it. Instead it adds to it. I need it to overwrite every time. Thanks in advance.

Sub logs()

CR = Chr$(rcCR)

Session.PrintToFile = "C:\EVDO Test Logs.xls"
Session.PrinterLogging = True

With Session
Wait 1
.Transmit "cd /appdata/logs" & CR
Wait 2
.Transmit "grep DOM_10.249.185.3/ alert_audit*" & CR
Wait 1


End With
Session.PrinterLogging = False
End
End Sub
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Just kill the file if it exists... I'm assuming that the file is created if it does not exist to begin with...

Sub logs()

CR = Chr$(rcCR)

on error resume next
kill "C:\EVDO Test Logs.xls"
on error goto 0

Session.PrintToFile = "C:\EVDO Test Logs.xls"
 
Upvote 0

Forum statistics

Threads
1,225,476
Messages
6,185,197
Members
453,282
Latest member
roger_nz66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top