0

I have written some code in Excel VBA which calls a macro in another workbook. The other workbook's VBA code is locked, but I can still run the macro itself. The macro does some calculations, then brings up a dialog box so the user can choose where to save the results.

After running this macro, I need the file path for the results file (to use the results in further calculations).

Is there any way to store the file path chosen by the user? Or alternatively, is there any way of automatically putting a specific file path in the dialog box to save to?

3
  • You can unlock the VBA code quite easily even though you don't know the password. Just google it. Maybe it can helpful for you... Commented Nov 25, 2016 at 15:24
  • Unfortunately I can't unlock the code because it would go against our license agreement. Good to know that it's possible to unlock code without a password though, in any case! Commented Nov 25, 2016 at 15:45
  • Show the code that prompts user for results path. In that dialog such a path is captured. Commented Dec 1, 2016 at 0:56

1 Answer 1

0

You can not get the file path directly. One workaround could be to use Application.RecentFiles(Application.RecentFiles(i).Path/Application.RecentFiles(i).Name). Unfortunately I don't have excel installed on my PC is I can't test if it really works.

If this workaround don't work, that there is no other way to get the file path. You would have to ask the user to select the file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.