VBA and command line

I am trying to run a powershell file from command line. What I need to do in command line is

cd D:\Scripts\WTV-MetaRenamer\
powershell -command "& 'D:\Scripts\WTV-MetaRenamer\wtv-metarenamer.ps1' "

I can figure out how to get this done in vba. I have search everything and tried shell and stuff, but I cant figure out how to run one line then the next

Sponsored Links:

Related Topics

Pass command line parameters
How can I pass a command line parameter to a function in a VBA module. I want to pass the name of a database to an import database function written in VBA


reg.exe through command prompt and Shell in VBA cause different behavior
I'm running Access 2010 32bit on Win7 x64 and was mostly aware of what it means in relation to registry and how it behaves with redirection, but was not aware it will cause discrepancy inhow included Windows libraries perform.

Here's description. Windows (from XP onward I think) include one brilliant little command line app reg.exe which enables tons of tricky operations with Registry in very simple manner. For example, I need to copy a key with subkeys and values to new location (from HKLM to HKCU).

This little app does it in a single line command! and can of course be used from VBA through Shell command.

However, same line run from command prompt and through Shell function copies different keys. The one through command prompt copies asked key, the one through Shell function copies redirected key (from Wow6432Node, instead from HKLM\Software).

Of course, I don't want that! I know everything will be fine on x32 Windows, but on x64 Windows it simply reads wrongkey.

And that's exactly what I tried to avoid by this approach! Is there a way to run reg.exe from VBA as if it's run from command prompt, or force it not to redirect?


IF statement
A very basic VBA question about IF . Else . End if

What I need to do is do the following

If "a certain condition is fullfilled" then
do this
and this
and this

Else
do that
and that
and that

End if

However when I write this in VBA editor in MS access, I get an error, it seems that the code dose not understand that "do this, and this, and this" should be executed if the condition is fullfilled, the code understands each line as a seperate command and it only executes the first line "do this" if the condition is met and not the other 2 lines "and this, and this" and I get other errors regarding Else and End if "that there is no if command"
how do you solve this so that VBA understands that the lines are "together


retrieving data from command line program
I'm a long time reader but first time poster.

I have a command line program that I need to call (with parameters) in access. The program prints a line out to the command line and then quits - I need to somehow get the data it prints into access.

Anybody got any ideas/experience in this


multi lined shell command?
I have some VBA in a MS Access module that properly and successfully executes a shell command that executes a batch file in the following manner:Shell("C:\runthisfile.bat")I am trying to actually place the contents of the batch file into the module. The problem is that the batch file is many lines. How would I write that?

Shell("ftp.exe -s:%0)
Shell("open myftpserver")
Shell("username)
..
..
..
probably 100 lines with each line being a separate shell command, but that doesn't work and neither does
Shell(" all lines")Is it possible to essentially shell many lines at the same time thereby making it possible to take say 100 lines resident in a batch file and just placing them all in the VBA module with shell command(s) instead of calling out the batch file that resides outside of the ms access file? It seems that I can only do single line shell commands?


Command button-Build Query/Report
with VBA, Access 2003. Basically I have a Database that track temporary employees: Names, Agency, line employee occupies, rate of pay and hours worked/week.

I want to create a command button that when I click on it, a Query or Report will be created after selecting "Agency" and "Week", and writing a name for the Query/Report, showing the following:

Agency
Temps who work for the agency
Line occupied
Hours worked that week.

I know almost nothing of VBA, if someone would be able to give me some "general" code from which I can start figure out


Command-line arguments for Access
I'd like to know if there is a Microsoft Access command-line argument that would allow me to compact the database upon opening.


Access Your Database From the Command Line
Building a Web site for personal use or for a small company is easy if you are familiar with the operating systems, servers and software programs that you need to put the Web site to work. Command lines and queries are quite simple to manage. Read on to learn how to access your database from the command line.


Format Graph Using Vba
Is there a method to format a graph using vba?

I need to create a line graph and, using VBA, would like to:
* set line colour
* set line thickness

Bearing in mind that the graph will have numerous lines


How to export MDB file in the command line in Windows?
I can export Tables from Microsoft Access MDB files using the export option, but my users have many tables to export, and it's cumbersome for them to do so.

Is it possible through Windows in the command line, to output an MDB file to a text file? If it's possible, then, I can put that command in a batch program and allow the users to easily do the export for many MDB files.

For example, at the command line:

MDBTOOLS <filename.mdb> <outputfile.txt&gt


Startup command-line options
This tutorial lists the Microsoft Access command-line options.


Command-line switches for Access
This article shows you how to customize the way that Microsoft Office Access 2007 starts by adding switches and parameters to the startup command. For example, you can have Office Access 2007 open a specific file or run a specific macro when it starts.
Command line switches are also called command-line options. Depending on what they do, some switches require parameters, and some do not.
In this article
* Introducing commands, switches, and parameters
* Use a switch once by adding it to the Run command
* Make a switch available for reuse by creating a shortcut
* Available switches and parameters


Stopping or Restarting an Access App From Command Line
I know I can start a .mdb using "Start C:\AppName.mdb" at the command line or in a .bat. Once open how would one stop or restart the same app from command


Query - aggregate function
This table is a bit more complicated than it looks because more or less every line is generated by a different data source. I have been trying for some time to work out a module which would calculate a percentage of Line 7 against Line 1, which would then populate Line 9.

For example field GCC in Line 9 should = (26/46)*100 to give me the % I require, however, to date I have singularly failed to work out either how to do this in VBA using the data source (its the same for both lines 1 and 7 in this case) or by doing an update query which keeps on giving me aggregate errors.

Doing this by VBA would be much easier for me - I'm dealing with 000s of potential lines across the tables I want to calculate, and having to write 3/4 queries to get to each line's result is going to be extremely onerous.


Passing a Parameter into a MS Access 2007 Form from Command Line
I'm trying to pass a parameter from one of my work's applications. This application runs command lines to get to the data, which is now stored in an Access database instead of separate Excel spreadsheets.

I can open the database and view the form I need just fine with the command line: "C:\Test.accdb" /ro /x Form1

The problem is that the user now has to select a value from a combo box in the form. Is there a way to pass a parameter from the command line from my work's application into that combo box? I've been searching for a way to do this,

Can I create a batch file or script that can do this?


Set command-line options for starting Access
Learn: 1)Start Microsoft Access with command-line options from the Microsoft Windows Start menu. 2)Start Microsoft Access with command-line options using a shortcut.


Passing a Parameter into a MS Access 2007 Form from Command Line
I'm trying to pass a parameter from one of my work's applications. This application runs command lines to get to the data, which is now stored in an Access database instead of separate Excel spreadsheets.

I can open the database and view the form I need just fine with the command line: "C:\Test.accdb" /ro /x Form1

The problem is that the user now has to select a value from a combo box in the form. Is there a way to pass a parameter from the command line from my work's application into that combo box? I've been searching for a way to do this, but I'm new to a lot of this. Can I create a batch file or script that can do this? Maybe something else?


Command Prompt
Can someone tell me how I can open Command Prompt and start writing command lines to the Command Prompt window in VBA?

e.g. This opens the Command Prompt window but I need to write lines to it via VBA

Shell ("cmd ")


Read Text field line by line
I have a text field that looks like
John Smith
34 Black Street
Liverpool
Queensland

I need some VBA to read the text, line by line, as I have to insert each line into other fields


Pass Command Line Variable to Macro
I have created a shortcut from within a custom program that from which I want to open an Access form for a given account and from within that program.

Command Line:
"C:\Program Files\Microsoft Office\Office11\msaccess.exe" "D:\ManatronProval\reports\mdb\database_name.m db" /Excl /X mcr_macro_name [ need to pass variable here if possible ]

There is an associated field in the Access db for a variable %PROPERTYNBR% I want to pass in the command line that I want to pass to the 'Where' property of the Access macro. I can find no other switches to apply after mcr_macro_name to populate macro properties. Maybe there are none?