Jump to content
Macro Express Forums

ME Prompt for filename to save as


hpram99

Recommended Posts

"Prompt for value" option within Variable Set String

 

This isn't a filesave option, it's "enter text here"

 

How many uses would you trust to know how to enter a full path and filename into a plain text box?

 

As your own signature states "I'm trying to make this foolproof, but I'm badly outnumbered."

 

 

Need a better solution. Anyone else?

Link to comment
Share on other sites

Open Notepad (empty file), type %T1% into the Notepad screen, then type ALTDOWN - F - ALTUP - A. That should open the "Save As" Windows panels and the user can type the filename and navigate to whatever folder he wants using screens that are (hopefully) familiar to him.

Link to comment
Share on other sites

Open Notepad (empty file), type %T1% into the Notepad screen, then type ALTDOWN - F - ALTUP - A. That should open the "Save As" Windows panels and the user can type the filename and navigate to whatever folder he wants using screens that are (hopefully) familiar to him.

 

 

Good idea thinking outside the box as I could output T1 to notepad.... only issue is how can I detect where the path is from that dialogue? once the variable is saved, my macro needs that path to throw it in the registry (among other things)

 

Still not the ideal solution.

 

I think I might have to post in the 3rd party solutions forum, or write a vbs that opens the save as box for me..

Link to comment
Share on other sites

Let's say I want to save %T1% to file, I want the user to be able to specify the file location and name.

How about something like this:

// Here: T1 contains information to be saved to the file

Variable Set String %T2% from File Name
If Variable %T2% <> ""
 Variable Modify String: Save %T1% to Text File
End If

<REM2:><REM2:Here: T1 contains information to be saved to the file><REM2:><TVAR2:02:09:Enter filename><IFVAR2:1:02:2:><TMVAR2:17:01:00:000:000:%T2%F><ENDIF>

Link to comment
Share on other sites

Hmmmm. You ask a question, get an answer, then you up the ante with additional requirements. Get an answer to that, and it turns out there are further requirements. That's called Scope Creep. You are obviously destined for a management position, not technical. :)

 

If your macro can get or keep control after the user does the save, then have the macro do "File | Save As" a second time. Then, if you can click the dropdown arrow at the end of the File Name box, it will open a list of recent names, and the one the user just specified will be at the top, including the complete file path. Now, click on that line and the complete file path will be brought up into the File Name box, already highlighted so you can simply copy it into the clipboard. At least that's the way my version of Notepad works.

 

The mouse operations to do this may be tricky, as far as positioning where to click. I tried to find some keystroke sequence to use instead of the mouse clicks, but was unsuccessful. Maybe you can find a sequence that will work.

Link to comment
Share on other sites

How about something like this:

// Here: T1 contains information to be saved to the file

Variable Set String %T2% from File Name
If Variable %T2% <> ""
 Variable Modify String: Save %T1% to Text File
End If

<REM2:><REM2:Here: T1 contains information to be saved to the file><REM2:><TVAR2:02:09:Enter filename><IFVAR2:1:02:2:><TMVAR2:17:01:00:000:000:%T2%F><ENDIF>

 

 

Looked perfect. Except when I enter the filename into the dialoge box, it says it cannot find it.... because it's trying to open an existing file.

 

For right now, I've got a series of commands like this:

 

<TVAR2:01:01:contents of file here><TVAR2:02:10:Select where you want to save this><TVAR2:03:02:FEnter a file nameFFCenter:Center><TVAR2:04:01:txt><TMVAR2:17:01:00:000:000:%T2%\%T3%.%T4%F>

 

Still not ideal, but much more useable. If there's any way we can get yours working Kevin, that would be fantastic.

 

rberq: I know, already there. Had to explain scope creep to another colleague requesting something because "I'm right there anyway" :rolleyes:

Link to comment
Share on other sites

Try this. Lots of delays built in so it's easier to watch it run. It's my suggestion from above, to pick up the file name after the user has saved the file. But it's done with keystrokes rather than with the mouse.

 

// Here: T1 contains information to be saved to the file

Variable Set String %T1% "File Content Here"

// Launch Notepad, type value into empty file, issue ALT - File - Save As s

Program Launch: "notepad.exe"

Text Type: %T1%

Wait Time Elapse: 0 Minutes 2 Seconds

Text Type: <ALTD>f<ALTU>a

Wait Time Elapse: 0 Minutes 2 Seconds

// Message box to user telling him to save file -- serves double duty by pa

Text Box Display: Save the file

// User will save the file, then macro regains control here.

Activate Window: "Notepad"

Wait For Window Title: "Notepad"

// Issue the ALT - File - Save As sequence, pick up the path just used for

// then ESC escape from Save As dialog.

Text Type: <ALTD>f<ALTU>a

Wait Time Elapse: 0 Minutes 2 Seconds

Keystroke Speed: 500 Milliseconds

Text Type: <ALTD><ARROW DOWN><ALTU><ARROW DOWN><ENTER>

Keystroke Speed: 0 Milliseconds

Clipboard Copy

Wait Time Elapse: 0 Minutes 2 Seconds

Text Type: <ESC>

Wait Time Elapse: 0 Minutes 2 Seconds

// File path and name is now in the clipboard. Move it to a variable for w

Variable Set String %T22% from Clipboard

// Text box display of file path, for debugging purposes.

Text Box Display: Debugging display

// ALT - F4 to shut down Notepad

Wait Time Elapse: 0 Minutes 2 Seconds

Activate Window: "Notepad"

Wait For Window Title: "Notepad"

Text Type: <ALTD><F4><ALTU>

 

 

<REM2:Here: T1 contains information to be saved to the file><TVAR2:01:01:File Content Here><REM2:Launch Notepad, type value into empty file, issue ALT - File - Save As sequence><LAUNCHDEL2:0:01C:\WINDOWS\system32\notepad.exe><TEXTTYPE:%T1%><WAITTIME:00000002><TEXTTYPE:<ALTD>f<ALTU>a><WAITTIME:00000002><REM2:Message box to user telling him to save file -- serves double duty by pausing the macro><TBOX4:T:4:000516000114000278000200:000:Save the filePlease select a folder and a file name for

saving the file.

 

AFTER you have saved the file, click OK to

close this message box. ><REM2:User will save the file, then macro regains control here.><ACTIVATE2:Notepad><WAITWIN2:000010:000000:Notepad><REM2:Issue the ALT - File - Save As sequence, pick up the path just used for the file save,><REM2:then ESC escape from Save As dialog.><TEXTTYPE:<ALTD>f<ALTU>a><WAITTIME:00000002><SPKEY:0500><TEXTTYPE:<ALTD><ARROW DOWN><ALTU><ARROW DOWN><ENTER>><SPKEY:0000><CLIPC><WAITTIME:00000002><TEXTTYPE:<ESC>><WAITTIME:00000002><REM2:File path and name is now in the clipboard. Move it to a variable for whatever else we need it for.><TVAR2:22:03:><REM2:Text box display of file path, for debugging purposes.><TBOX4:T:1:CenterCenter000278000200:000:Debugging displayFile path saved by user is

%T22%><REM2:ALT - F4 to shut down Notepad><WAITTIME:00000002><ACTIVATE2:Notepad><WAITWIN2:000010:000000:Notepad><TEXTTYPE:<ALTD><F4><ALTU>>

Link to comment
Share on other sites

If the file does not already exist I ask the user to pick a folder with the Variable Set String and choose the Set Value to Folder Name (Prompt) EG T1. Then I use Prompt for value to as them for a file name EG T2. I then save the file with Variable Modify String - Save to Text File with something like %T1%%T2%.txt. Sometimes one needs to do something about the extension too. I add a routine to check if there is a period 4 characters from the end and if there is I don't try to add or prompt for a file extension. Then it pays to check to see if the file already exist and if it's locked.

Link to comment
Share on other sites

If the file does not already exist I ask the user to pick a folder with the Variable Set String and choose the Set Value to Folder Name (Prompt) EG T1. Then I use Prompt for value to as them for a file name EG T2. I then save the file with Variable Modify String - Save to Text File with something like %T1%%T2%.txt. Sometimes one needs to do something about the extension too. I add a routine to check if there is a period 4 characters from the end and if there is I don't try to add or prompt for a file extension. Then it pays to check to see if the file already exist and if it's locked.

 

Yes, this is what I'm doing, see post #8 above

 

http://pgmacros.invisionzone.com/index.php...ost&p=11872

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...