|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
Save As Dialog Box
Hello to all. I have a script that parses a specific line out of multiple text files in one folder. The problem is this: The parsed information is put in a file in a specific location. How can I bring up a Save As dialog box so that I can choose were to save this file? The code to this script is pasted below and Thanks to all in advance.
Dim fs, ts1, sf, s1, ts2, ProjectDir, WshShell Const ForReading = 1, ForWriting = 2, ForAppending = 8 FirstPrompt = "Enter Project Directory:" ErrorMessage = "Operation failed or was canceled!" & vbCrLf & vbCrLf &_ "Please repeat the operation." FinalMsg = "Map Totals operation complete!" ProjectDir = InputBox(FirstPrompt,"Map Totals") Set WshShell = WScript.CreateObject("WScript.Shell") Set fs = CreateObject("Scripting.FileSystemObject") If ProjectDir = "" Then Dummy = WshShell.Popup (ErrorMessage,0,"Map Totals",16) Wscript.Quit Else WshShell.Run "Cmd.exe /C Copy C:\Cablview\" & ProjectDir & "\Dgn\*.txt C:\Cablview\" & ProjectDir & "\Temp\Totals.txt", 2,True Set ts1 = fs.OpenTextFile("C:\Cablview\" + ProjectDir + "\Temp\Totals.txt", ForReading) Set ts2 = fs.OpenTextFile("C:\Cablview\" + ProjectDir + "\Temp\Miles.txt", ForWriting, True) ReadTotals Sub ReadTotals() Do While Not ts1.AtEndOfStream s1 = ts1.ReadLine() If InStr(s1, "FTG") > 0 Then ts2.WriteLine s1 End If Loop ts2.Close ts1.Close Set ts2 = Nothing Set ts1 = Nothing Set fs = Nothing End Sub End If |
|
#2
|
|||
|
|||
|
To see http://forums.devshed.com/showthrea...save+dialog+box
the Code from PHP-Newb: <HTML> <BODY> <IFRAME id="newFrame" style="display:none"></IFRAME> <SCRIPT> function SaveFile(){ var newinfo = "<html>"; newinfo += "<body>This is text from the secondary page.</body>"; newinfo += "</html>"; newFrame.document.open("text/html","replace") newFrame.document.write(newinfo) newFrame.document.close() newFrame.focus() newFrame.document.execCommand('SaveAs',false,'testfile.txt'); } </SCRIPT> This is text from the main page.<BR> <A HREF=# onClick="SaveFile()">Click to save secondary page.</A> </BODY> </HTML> |
|
#3
|
|||
|
|||
|
cleverpig, what does html/javascript code have to do with Visual Basic?
|
|
#4
|
|||
|
|||
|
i need a way to prompt for a saveas dialog box (or a common dialog box) using VBcode.
thanks. |
|
#5
|
|||
|
|||
|
You should be able to use a inputbox at the appropriate spot.
MyPath = Msgbox("Enter The Path: ") In VB6 there is also the common dialog control that gives you the standard windows Open / Save As functionality. |
|
#6
|
|||
|
|||
|
MyPath = Msgbox("Enter The Path: ")
Inserting the above code gives me a small message box with an OK button, but know browse button, or know text box for the path. Also, I've been researching extensivly, but I can't seem to figure out WERE in my code to put the common dialog control, nor the syntax of it. Ya'll I'm struggling here. Thanks in advance. |
|
#7
|
|||
|
|||
|
What version of VB are you using?
|
|
#8
|
|||
|
|||
|
I'm not, I'm using Notepad. And the file's extension is .vbs. I believe it is called Windows Scripting - not sure.
|
|
#9
|
|||
|
|||
|
I find a way by vb.net...Hope it's useful..Good luck!
'Put this is a code behind module or asp.net page Sub DisplayDownloadDialog(ByVal PathVirtual As String) Dim strPhysicalPath As String Dim objFileInfo As System.IO.FileInfo Try strPhysicalPath = Server.MapPath(PathVirtual) 'exit if file does not exist If Not System.IO.File.Exists(strPhysicalPath) _ Then Exit Sub objFileInfo = New System.IO.FileInfo(strPhysicalPath) Response.Clear() 'Add Headers to enable dialog display Response.AddHeader("Content-Disposition", "attachment; filename=" & _ objFileInfo.Name) Response.AddHeader("Content-Length", objFileInfo.Length.ToString()) Response.ContentType = "application/octet-stream" Response.WriteFile(objFileInfo.FullName) Catch 'on exception take no action 'you can implement differently Finally Response.End() End Try End Sub 'DEMO 'IN YOUR CODE BEHIND PAGE: 'DECLARATION Protected WithEvents btnDownload As _ System.Web.UI.WebControls.Button 'IN CODE 'ASSUMES MYWORDFILE.DOC EXISTS IN SAME FOLDER 'AS THE ASPX FILE Private Sub btnDownload_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btnDownload.Click DisplayDownloadDialog("MyWordFile.doc") End Sub 'ON APSX PAGE <asp:Button id="btnDownload" runat="server" Text="Download a Word File"></asp:Button> |
|
#10
|
|||
|
|||
|
Cleverpig, not sure what you mean by creating an ASP page or module! I mean, I allready have the bulk of the code wrote. I just need a way to choose were to save the page. My code is at the top of this page. Thanks.
|
|
#11
|
|||
|
|||
|
Yep, if you are using a .vbs file on your computer it's Visual Basic Scripting Edition. I don't know how to get to any pre-built file dialog from vbs, I don't do that much scripting outside of ASP.
I meant to use InputBox instead of MsgBox above. InputBox gives you an input field and a return string value. The MS scripting documentation starts here http://msdn.microsoft.com/nhp/Defau...tentid=28001169 Maybe poking around in the docs for Windows Script Host (what you're apparently using) and the VBScript docs will turn up something that will help you out. |
|
#12
|
|||
|
|||
|
hi!jacksonbilly! My code can be used as vbs...
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Save As Dialog Box |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|