Question

I'm attempting to run windows powershell through VBA in excel, while passing variables from VBA. ...

I'm attempting to run windows powershell through VBA in excel, while passing variables from VBA.

My code works successfully in powershell, but I get an error that says "The string is missing the terminator" when attempting to run the script through VBA. I also get an "Expected: list separator" error within VBA.

The code that I use in powershell is:

Get-ChildItem “H:\Users\Desktop\A Folder With Subfolders Containing Files” -Recurse -Filter "*.xlsm" | Copy-Item -destination “H:\Users\Desktop\A Different Folder I Want All the Files To Be In\”

What this does is it takes files nested within subfolders, and copies them without the subfolders into a different folder, ie. it flattens the folder hierarchy.

I am trying to run this powershell code from a VBA macro. This is my following code I am using to do so, but I am getting the above described errors.

Set source = H:\Users\Desktop\A Folder With Subfolders Containing Files

Set destination= H:\Users\Desktop\A Different Folder I Want All the Files To Be In

Shell("PowerShell -noexit ""&source&"" -Recurse -Filter "*.xlsm" | Copy-Item -destination ""&destination&"", vbNormalFocus)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Kindly provide the code.

Provide the code in commenta and i will solve it for you.

Looking forward for your reply.

Thanks.

Add a comment
Know the answer?
Add Answer to:
I'm attempting to run windows powershell through VBA in excel, while passing variables from VBA. ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • Ensure the following compiles 5. Variable scope (1 mark) Some variables are only accessible while executing...

    Ensure the following compiles 5. Variable scope (1 mark) Some variables are only accessible while executing specific code. Global variables are often thought of as evil because the state of a system can be altered making functions execute differently when it isn't expected. There is also the issue of block scope. For an example of block scope, see the file below. Notice that you don't get an error because the code uses the correct syntax. Although the syntax is correct,...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

  • I've posted 3 classes after the instruction that were given at start You will implement and...

    I've posted 3 classes after the instruction that were given at start You will implement and test a PriorityQueue class, where the items of the priority queue are stored on a linked list. The material from Ch1 ~ 8 of the textbook can help you tremendously. You can get a lot of good information about implementing this assignment from chapter 8. There are couple notes about this assignment. 1. Using structure Node with a pointer point to Node structure to...

  • This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation...

    This C++ Program consists of: operator overloading, as well as experience with managing dynamic memory allocation inside a class. Task One common limitation of programming languages is that the built-in types are limited to smaller finite ranges of storage. For instance, the built-in int type in C++ is 4 bytes in most systems today, allowing for about 4 billion different numbers. The regular int splits this range between positive and negative numbers, but even an unsigned int (assuming 4 bytes)...

  • Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class...

    Activity: Writing Classes Page 1 of 10 Terminology attribute / state behavior class method header class header instance variable UML class diagram encapsulation client visibility (or access) modifier accessor method mutator method calling method method declaration method invocation return statement parameters constructor Goals By the end of this activity you should be able to do the following: > Create a class with methods that accept parameters and return a value Understand the constructor and the toString method of a class...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT