Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-14-2019, 10:36 AM
DaveP DaveP is offline Input Box Help/Storing Variables in other Macros Windows 10 Input Box Help/Storing Variables in other Macros Office 2010
Novice
Input Box Help/Storing Variables in other Macros
 
Join Date: May 2019
Posts: 11
DaveP is on a distinguished road
Default Input Box Help/Storing Variables in other Macros

Hello,


(start at the ** if you don't care about context)

I wrote a program that uses userforms to open up documents from our file explorer and network, as well as run simple macros (mostly formatting). The goal is to save time; we open 5 or 6 different documents on every case, and do ~20 cases per day, so having a userform that offers you those documents, rather than dig through 6 different folders, is a huge deal (believe, me I understand how inefficient that all sounds, but if you knew what we do, it makes sense, I promise, ha).

I'm trying to build a macro that will open a document that has not been created yet. Let's call it AutoText. The department that creates AutoText has not yet made the doc, but I don't want to have to update the user's copy of the program every time we write a new AutoText document, if that makes sense.

*********Basically, I want an input box where you paste a file location, and what you pasted gets added to a macro that opens that file location, and stores the file location for future use.

Sub Send()
InputBox ("File Location: click the files tab; underneath the document title, click the file path, then click 'Copy Path to Clipboard'")
'What goes here? How do I paste to "Sub Receive"?
End Sub

Sub Receive()
'Auto Texts file opener
Shell "Explorer.exe ***the file location entered in the Sub Send input box***", vbNormalFocus
End Sub


So the user would input

C:\Users\davep\Desktop\Files\AutoText.docx

and press enter, and then Sub Receive would now say:

Sub Receive()
'Auto Texts
Shell "Explorer.exe C:\Users\davep\Desktop\File\AutoText.docx", vbNormalFocus
End Sub


Now, in the userform, I have a command button:

Private Sub CommandButton4_Click()
Call Receive
Me.hide
End Sub

So after inputting the file location in Sub Send, Sub Receive now opens AutoText.docx, and when you click CommandButton4, Sub Receive runs, opening AutoText.docx.

TL;DR:
I have an Input box, I want the user to add a file location, it stores the file location to a macro, with a shell command that opens that file location--- that macro is called upon by a command button attached to a userform. How do I store an input box answer inside of an existing macro?
Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro keyboard commands and storing them swepo Word 7 12-15-2018 11:44 AM
Array to iterate through variables and trap blank variables Marrick13 Word VBA 5 08-04-2015 06:19 AM
Input Box Help/Storing Variables in other Macros Code for storing new word fahmiakbar Word VBA 2 02-13-2015 11:26 AM
can word: make variables, find appropriate pages, fill out pages with variables, print only those 20GT Word VBA 1 10-15-2014 09:48 PM
Creating Wizards with Input Variables marka Excel Programming 1 11-11-2012 09:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft