Create bat file with Excel Data

manny_56

New Member
Joined
May 17, 2007
Messages
2
Hi,

I need help to create a batch file from the data captured in Excel.

I have created a macro (through recording macros - I'm not good with VB) that opens a text file containing printer details, cleans the data in the text file and uses certain formulas to produce data as below:

CALL SQ Printer1 \\Server1 >> C:\Printers.txt
CALL SQ Printer2 \\Server1 >> C:\Printers.txt
CALL SQ Printer1 \\Server2 >> C:\Printers.txt

I now need to save the info in my Excel spreadsheet as a batch file which on execution will give me printer IP address, location and driver details etc. Excel does allow me to save the file with a .bat extension but the data doesn't appear as it should and hence doesn't execute as it should.

Does anyone know of a way I can save the info from Excel as a batch file (using a macro - currently, I select all cells, copy them into notepad and save with a .bat extension and everything seems to work but it would be better if I could automate the whole process)?

Thanks in anticipation.

Regards,

Manny
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Write it using the FileSystemObject of the Microsoft Scripting Runtime.
 
Upvote 0
Hi Oorang,

Thanks for your promt reply. I had been messing around with the different save formats and around the same time as receiving your reply, the following also worked for me:

Sub CreateBatFile()

ChDir "C:\"
ActiveWorkbook.SaveAs Filename:= _
"C:\Printers.bat", FileFormat:= _
xlTextPrinter, CreateBackup:=False
End Sub

Thanks again for your help.

Regards,
Manny
 
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,297
Members
448,564
Latest member
ED38

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