Get Command Line From Batch File Put It Into VBA
Dec 17, 2012
i have batch file that run from VBAexcel But the thing is i dont want to run batch file
i want everything on VBA . for example you use vba to cmd and then run this line of command
i have try but i just new to VBA and programing
how can i do it
here the code
this is from batch
Code:
@echo off
>summary.txt (
for %%F in (*chkpackage.log) do findstr /l %1 "%%F" nul||echo %%F:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A:N/A
)
and this is code in vba
Code:
FileSet = Sheet1.Range("C13")
txtFpath = Sheet1.Range("C7").Value
FilePath = txtFpath & "
es.bat"
[Code]...
i have to admit that i'm really not good in programing if you can add some explaination is a great thing for me to try to study
View 1 Replies
ADVERTISEMENT
Jul 13, 2009
I was trying to run the shell command in VBA (excel2007) on a .BAT(batch) file. While running the macro, the DOS command prompt appears and goes away in a flash but the function of the .bat is not performed which makes me think that the shell command isnt functioning properly. I had this proper earlier also with a few Exe's.
the line of the macro that calls is (c is the path for the batch file) :
Call Shell(c, vbNormalFocus)
Could any of you help me with some suggestions regarding this problem.
Just to confirm, the batch file on itself works absolutely fine and it looks like it doesnt take more than 2 seconds to run it. It also does not wait for any input from the macro. it is an individual batch just included in the macro.
View 15 Replies
View Related
Oct 28, 2008
I know this is an excel forum but i'm struggling with something. i need to create a batch file that maps a network drive so far my searches have uncovered this
View 3 Replies
View Related
Apr 22, 2008
Is their a way of creating a batch file which will open an Excel workbook and run a single macro?
View 9 Replies
View Related
Dec 9, 2011
I'm working on my first VBA project that requires 12 fields to be manually input of which one field is a file path. I need this path for multiple reasons, but the one reason I'm having a problem with is using the location of the path in conjunction with calling a bat file or executing a cmd prompt that is at that path.
Path Location, minus file name:
Code:
sheets("b. Fill Out Required Info").Select
Range("B18").Select
Actual Path found in B18:
C:UsersNickDesktopSubmission ToolTest Files
File attempting to execute:
CopyFileNames.bat
I can manually put all of this together and get what I want by using:
Code:
Shell "C:UsersNickDesktopSubmission ToolTest FilesCopyFileNames.bat", 1
The problem is, every time this will be used, a different path will be used, but the same batch file name will be used. So, rather than having to manually input the file path every time, is there a way to replace "C:UsersNickDesktopSubmission ToolTest Files" with the cell reference of the path listed above? I've tried different methods of this but I cannot seem to get it.
It would be even better if I could just use the cmd prompt found within the batch and run it directly from vba; the prompt I'm running is as follows:
Code:
cd C:UsersNickDesktopSubmission ToolTest Files dir /b/o |find ".xml">ListOfFileNames.txt
How can I put that cmd into VBA? I tried different versions of this with no success:
Code:
Shell "cmd.exe /c cd C:UsersNickDesktopSubmission ToolTest Files dir /b/o |find ".xml">ListOfFileNames.txt"
Notice that the path is the same as the path shown in B18 above. It would be great if that path would be dependent on the cell referenced above.
View 9 Replies
View Related
Oct 11, 2008
I realise this is not strictly an excel question but it forms part of my VBA code within excel
I have been writing a VBA program (with some fantastic help from you guys) part of which writes to a batch file to rename files stored in a given folder. Unfortunately this fails if the original files have spaces in the filenames. The batch file contains command lines such as: ...
View 6 Replies
View Related
Feb 24, 2009
I wanted to run a batch file which does something like,
Dir /b >Test.csv
Start Test.csv
And then runs an Excel macro once the workbook is open.
I looked into this and discovered that it’s not really that possible to run an excel macro through batch file but other options were to use ‘Workbook_Open’ etc.
I thought this might cause problems because Test.csv doesn’t contain a macro to auto open and because csv’s usually don’t like macros.
I do however have personal.xlsb which opens every time if that helps.
View 6 Replies
View Related
Oct 23, 2013
I have a workbook that contains worksheets. They are listed as follows:
Sheet 1ABCDEFG
In cells A1 - A49 I have text. What I would like to do is to have a macro that I can run that will basically copy and save new workbooks with sheets A - G copied over and have the new workbook saved with the file name that I have denoted in cells A1 - A49 on Sheet 1. Also, the macro would ask me where I want to save the new Workbooks.
For example, if this were Sheet 1, Column A then the cells below would be the saved name of the new workbooks and the new workbooks would have Sheets A - G in themRed
Blue
Purple
Black
White
Yellow
Orange
Green
Gray
Brown
One more piece of information, the file that is being copied and saved is large (~80MB). If there is a macro that would allow me to simply "save as' the workbook and the Saved Workbooks would be named using the data in Sheet 1, that would work as well in case copying, pasting, then saving may take more time
View 1 Replies
View Related
Feb 23, 2013
I have the data to import / read in a pdf, in a doc, or in an Excel worksheet whichever is easier to use. I need to import the data, parse it into the correct cells for that row and then repeat the import until the end of the file. Not all the cells are in each group of data to import, so those cells will be null for that row. Some of the data for one cell may be in up to 14 lines in the data file. I have be concatenating these data rows into one cell. There are 48,000 lines in the file to import or I would do this manually. I am assuming that doing this in VBA would be the most efficient method.
View 11 Replies
View Related
Mar 7, 2006
Is there any way to run a command line from excel?
E.g. i want excel to call this command:
ping 10.100.100.100 and then return the result to a txt file?
View 9 Replies
View Related
Mar 27, 2008
How can I get at parameters passed on a command line to Excel 2007?
For example invoking Excel from Vista's Run command with:
"C:ProgramDataMicrosoftWindowsStart MenuProgramsMicrosoft OfficeMicrosoft Office Excel 2007" "C:GZNORPWeather StationParamTest1.xlsm" /e/abc/def
Should reveal the parameters "abc" and "def". But this does not happen!
Supposedly, the API function GetCommandLine does this, but I cannot seem to get it to work. Here's a sample of what I've been trying:
View 9 Replies
View Related
Feb 10, 2012
I've got an Excel file that uses 7-zip. It can execute a command line that will use 7-zip to go to a folder and zip each of the folder's files into its own zip file, placing the zips in a single, specified destination folder. I can specify whether to look in the source folder, or to also look in all of the source folder's subdirectories.
Question is, how do I tell 7-zip to just zip ONE file, and how do I tell 7-zip to zip a SPECIFIC LIST of files that I name (instead of looking through a whole folder)? how to use command line...
Code:
Sub a_zip_with_sub_directories()
Shell "cmd /c for /r ""C:Users aiDocumentsmonthly reportsFinal Copies of Monthly Reports"" %i in (*.*) do ""%ProgramFiles%7-Zip7za.exe"" a -tzip ""C:DATA aiipped\%~ni"" ""%i"""
End Sub
Sub a_zip_no_sub_directories()
Shell "cmd /c for %i in (""C:Users aiDocumentsmonthly reportsFinal Copies of Monthly Reports*.*"") do ""%ProgramFiles%7-Zip7za.exe"" a -tzip ""C:DATA aiipped\%~ni"" ""%i"""
End Sub
View 2 Replies
View Related
Mar 25, 2004
Is there a way to print an Excel Workbook from the command line? Is there a command line reference anywhere for Excel?
View 9 Replies
View Related
Oct 17, 2008
I found the following link that got me started [url], so now I have my code for reading/analyzing comand line parameters. Here is an example of the parm I'm passing in ....
View 9 Replies
View Related
Oct 8, 2012
I have a userform with a numerous textboxes, which I have labeled with similar text and a unique number at the end (num1_txt, num2_txt, num3_txt, etc.). I am trying to create a for loop that sequentially references the numbers of the text boxes and pulls the user-entered value in the text boxes into an Excel document.
Here is the code I have so far...
VB:
i = 1
For i = 1 To 18
Dim cyltrack As String
cyltrack = "Me.cyltrack" & i & "_txt.Text"
If Me.cyltrack.Value = "" Then
Cells((cellcount + i), 13).Value = "*"
Else
Cells((cellcount + i), 13).Value = cyltrack
End If
Next i
I am running into problems in trying to convert the string variable, cyltrack, into hard code that I could insert into Me.cyltrack.Value.
View 4 Replies
View Related
Feb 26, 2007
I have created an AddIn for a project I'm working on using the 'Open' command in Excel Vb. While this worked perfectly for the file I was testing it on (1,740,754 bytes) it doesn't work on a new file (121,445,125 bytes).
On testing the code, one line at a time, it gets stuck on
Line Input #1, DataLine
The files only contain one line so I suspect there is too much data for the command to handle.
Is there an alternative?
View 9 Replies
View Related
Jan 28, 2014
I'm looking to have an excell file shared on a windows network to a simple LAN (samba sharing), and then for a user to be able to click on a HTML link that will launch that excell pile, and to have it populate specific and predeterminined cells with information that will be handed to it by the HTML link from the website.
Think of a CRM web app that href is a link like: "LAN1Filesexcellbook01.xls?Mrs%20Wendy%20Jones?4%20Skin%20Street"
From something like that I would like to launch excell and have Mrs Jones' details populate into the predefined excell sheet. The HTML website can dynamically populate a HTML link depending on the customer being viewed.
So I'd like to know how two things
1) How to launch a network file in this way, while correctly handing it parameters or switched that it will be able to later:
2) Collect that information and distribute it into the cells I choose in VBA.
I'm familiar with Visual Basic .Net primarily, and have a small amount of VBA experience.
We would like to continue to use Google chrome if possible...
View 5 Replies
View Related
Jul 31, 2014
I've recently created a macro which takes a .csv file and scrubs the data and dresses it up for a report. I've finally got it running without any problems and have added it individually to 5 different user accounts on my network as an add-in, but need a way to share it across a computer network without allowing others to edit the file.
The report is generated multiple times a day by the different users, none of whom are very computer literate (not that I am much better, myself), and the macro over-writes the old file each time. I've read that it's possible to simply create a shortcut to the file that automatically opens the spreadsheet in read-only format, which would be perfect for what I'm trying to do, but I haven't been able to get it to work so far.
My current shortcut pathway is similar to this:
"C:Program FilesMicrosoft OfficeOffice15EXCEL.EXE" /R "C:UsersBenDocumentsOT Master.xlsx"
On my computer at work (Windows 7) the shortcut simply opens the spreadsheet so that anyone can edit it, instead of as a read-only file. On my computer at home (I'm trying to experiment) (windows 8.1) it won't even let me save the shortcut, saying I need to provide administrator permission & then cutting to a window that says "access denied".
I won't have the pathway for the actual file I'm trying to create a shortcut for until tomorrow when I get back to work, but I've formatted it essentially the same, directing to the excel.exe file, running the switch "/R", and then directing it to the actual file location.
The ultimate goal is to have multiple people be able to view the file without locking out those who need to update it.
View 1 Replies
View Related
Apr 24, 2009
when I link cells from one file to another and insert a new line on the file I am linking to. the file that is linking goes down as follows:
=Safety.xls!$A$5
=Safety.xls!$A$6
How do I get Cell A5, to link to Cell A5 even if I add a new line in the Safety.xls spreadsheet. Taking the $ away does not work I have tried that.
View 3 Replies
View Related
Mar 31, 2007
I have two sheets and two listbox's(ColumnCount8) and one command button.
lstInYard rowsource is set to sheet1
lstMilled rowsorce is set to sheet3
Iam trying to cut and paste the selections in lstInYard to lstMilled as well as the corrosponding row values in sheet1 to sheet3 by using cmdMoveSelected click event.
View 9 Replies
View Related
Mar 17, 2009
I have created a large process map workbook in excel that links to various areas within the document using command buttons.
However, one of the things I need users to be able to see s in a PowerPoint presentation.
All I need to do is create a command button that links to, and opens this .ppt file.
The .xsl and .ppt files will be distributed in a folder to other members of the team so I need the link to not be specific to my computer. Is it possible to avoid using the full path and just use a short path such as .../desktop/tools/process.xls so that as long as they store the folder on their own desktop the link works?
View 6 Replies
View Related
Mar 1, 2007
I have a wb with hyperlinks that open other .xls files stored on the LAN. When these files open, the Web Commandbar is displayed. I ran a macro to turn it off, then pasted the following code in the wb module but it doesn't work.
Private Sub Workbook_Open()
Application.CommandBars("Web").Visible = False
Application.Goto Reference:=Worksheets("Deviation Form").Range("A1"), _
Scroll:=True
End Sub
View 6 Replies
View Related
Jun 21, 2009
I've download the CSV files from my bank. Somehow I thought they'd import painlessly. I dunno what's happened, these files are bloody ridiculous to look at.
Somehow I've ended up w/ Date, then Amount in the cell under it, then a description of what I bought in the cell below, and then something to the cell to the right of it (a further description sometimes, at other times nothing).
I have about 1500 lines of this so doing this automatically is not in question. I want to figure out how to run a macro to organize this. The logic is fairly simple. Where-ever the cursor is, copy the stuff in there over 2 lines, go back to original starting point, copy next cell, paste it next to where i previous pasted, goto third line, copy, paste next to second place i pasted, and then goto next set of data/dates. So I did that once figuring it could keep repeating the cycle. NOOOO that didnt happen. I did this for one set and then just stopped. Everytime I run the macro it deals w/ the same data. For example I created the macro to start of w/ cells A2, A3, and A4, then goto A6 and stop. I figured once there I could run the macro again, and it would do the same stuff for A4, A5, and A6 that it did for the previous one. Nope, it went back to A1-3.
Of course if someone can give a better idea of how to work w/ CSV in the first place that would also help. It just never made the colums in the right place. I got to choose the variables that would decide when a new column starts but I was never really getting the result I wanted. If this macro works though I wont need to work w/ that anymore.
Here's a sample though of how my CSV looks at the moment. These are three entries. The first one's description takes up one cell, the next 2 have 2 cells each.
D06/13/2008
T-20.00
MABM WITHDRAWAL
^
D06/16/2008
T-26.25
MMISCELLANEOUS PAYMENTS Good Life
^
D06/16/2008
T-25.00
MPOS MERCHANDISE AMC MISSISSAUGA
View 6 Replies
View Related
Aug 26, 2006
how to write a new line to a csv file? Or how to write a "Character return" to the file? I use the following code to write a line but I don't know the command to start a new line. Write #1, "abc",
View 2 Replies
View Related
Jan 16, 2010
What is the code to open a URL or local html file with a command button?
View 4 Replies
View Related
Jan 1, 2007
Say there is a HTML file at C:DataFile.html
I'd like to use Excel VBA to write this meta tag into that HTML file:
****** http-equiv="refresh" content="600">
That's to make it refresh every 600 seconds.
The most elegant way would be to locate the "head" tag and write it right after it, but the refreshing meta tag seems to work where ever it is, even at the very end of the file after the "/html" tag! So locating the "head" tag is not that important, if it's difficult.
So, how do I use VBA to write lines into a HTML (or any text) file?
View 9 Replies
View Related
Oct 26, 2006
I'm using the following code to read a text file that I downloaded from a mainframe file.
Do While Not EOF(FileNum)
Line Input #FileNum, myLine
Debug.Print myLine
Loop
It reads and prints the first line, but then drops out of the loop. According to the help file, "Line Input" is looking for a carriage return (Chr(13)) or carriage return–linefeed (Chr(13) + Chr(10)) sequence. I have pasted a sample of the text file below. I'm not sure what the characters are at the beginning of each line, but perhaps I could find a way to replace each of them with a carriage return.
SAMPLE:............................
View 4 Replies
View Related
Mar 28, 2007
I am using Chip Pearson's example of importing text into my worksheet.
Sub ImportTestFiles()
ImportTextFile "C:Documents and SettingsKevMy Documents est.txt", ","
End Sub
Public Sub ImportTextFile(FName As String, Sep As String)
Dim RowNdx As Long
Dim ColNdx As Integer
Dim TempVal As Variant
Dim WholeLine As String
Dim Pos As Integer
Dim NextPos As Integer
Dim SaveColNdx As Integer
Application. ScreenUpdating = False
On Error Goto EndMacro:
SaveColNdx = 1
RowNdx = Range("A65536").End(xlUp).Row + 1
Open FName For Input Access Read As #1 ...
View 3 Replies
View Related
Jun 19, 2007
I use the Append command to write a line to a text file. I have about 3 excel files appending data to the same text file.
If someone were to write a line in error I would like to have the ability to delete it.
View 3 Replies
View Related
Apr 14, 2006
The VBA shell command is as follows:
programPath = "C:Program FilesInternet Exploreriexplore.exe" ' works
'programPath = "iexplore.exe" ' does not work
Shell programPath + " " + fileToLaunch, vbNormalFocus
but the drawback is that the invoked program (iexplore.exe, at least in my case) needs to have the FULL PATH to where the program exists = the "C:Program FilesInternet Explorer" which may or may not work on someone elses computer. This hardcoding will not work and is not transportable.
Is there a trick to find where the executing program lives? or launching it without the path?
View 9 Replies
View Related