473,854 Members | 1,491 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

save file dialog?

how can i create a code to make my program create an rtf file? heres what i
have so far, any help would be appreciated:
Private Sub MenuItem2_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles mnuSave.Click
Me.SaveFileDial og1.ShowDialog( )
Me.SaveFileDial og1.CheckFileEx ists = True
Me.SaveFileDial og1.CheckPathEx ists = True
Me.SaveFileDial og1.AddExtensio n = True
Me.SaveFileDial og1.Dereference Links = True
Me.SaveFileDial og1.DefaultExt = ".rtf"
End Sub
Nov 21 '05 #1
21 7205
SaveFileDialog1 .Filter = "RTF Files (*.rtf)|*.rtf"
Nov 21 '05 #2

That still didnt work, should it look like:
Private Sub MenuItem2_Click (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles mnuSave.Click
Me.SaveFileDial og1.ShowDialog( )
Me.SaveFileDial og1.CheckFileEx ists = True
Me.SaveFileDial og1.CheckPathEx ists = True
Me.SaveFileDial og1.AddExtensio n = True
Me.SaveFileDial og1.Dereference Links = True
Me.SaveFileDial og1.Filter = "RTF Files (*.rtf)|*.rtf"

End Sub
Nov 21 '05 #3
Dim strFilename As String
With SaveFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|A ll Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirecto ry =
Environment.Get FolderPath(Envi ronment.Special Folder.Desktop)
If .ShowDialog = DialogResult.OK Then
strFilename = .FileName
Else
Exit Sub
End If
End With
MessageBox.Show (strFilename)
Nov 21 '05 #4
i put that in, it says its saved yet the file isnt there
Nov 21 '05 #5
You originally asked about the file save dialog, which you got.

Here;s the full code to create the file too:

Dim strFilename As String
With SaveFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|A ll Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirecto ry =
Environment.Get FolderPath(Envi ronment.Special Folder.Desktop)
If .ShowDialog = DialogResult.OK Then
strFilename = .FileName
Else
Exit Sub
End If
End With
Dim sw As New IO.StreamWriter (strFilename)
sw.Close()

That will do the trick. Just copy/paste it in your menu click event.

By the way: It creates an EMPTY file & closes it.
Nov 21 '05 #6
if i go to the open dialog will the file open and have everything that was
shwon on the screen?
Nov 21 '05 #7
RTF files are usually handled by MS Word or Wordpad if MS Office isn't
installed. You will notice the file icon is either Wordpad or MS Word

So, use the same idea as the save file dialog & it shall open
Nov 21 '05 #8
whats the open file code if i wanted to open this file? and will it show it
exactly how i left it if there are pictures, labels, and text boxes or should
i use a different file format?
Nov 21 '05 #9
The code that goes between the StreamWriter & the close should be from a RTF
textbox & not a normal textbox.

Then use this code (incomplete) to open a Stream Reader object to put the
file into your RTF textbox:

Dim strFilename As String
With OpenFileDialog1
.DefaultExt = "rtf"
.Filter = "RTF (*.rtf)|*.rtf|A ll Files (*.*)|*.*"
.FilterIndex = 0
.InitialDirecto ry =
Environment.Get FolderPath(Envi ronment.Special Folder.Desktop)
If .ShowDialog = DialogResult.OK Then
strFilename = .FileName
Else
Exit Sub
End If
End With

As you see, its the same code, but using an OpenFileDialog instead.
Nov 21 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
4190
by: cathywigzell | last post by:
I have a web page which allows a user to download a file directly to their computer, using IE. I present a file name in a table and the user can then right click on the file name to get a popup menu with the option 'Save Target As...'. Selecting that option results in the Save As dialog. However, if the filename has a reconginsed extension, e.g. .doc, then the Save As dialog adds another extension, so the file name in the Save As dialog...
2
2373
by: Alvo von Cossel I | last post by:
hi, i have a textbox in a form. when you press a Save button, a savefiledialog appears. creating ther file works but everytime you click save, the dialog appears. how do i make the dialog appear once and then only save the file? thanx -- Alvo von Cossel I of Germany
4
5119
by: John | last post by:
Hi, I generate a report in a comma delimited file and give it a name like MyReport.csv . I then set a Hyperlink control to point tp the file HyperLink1.text = "Download" Hyperlink1.NavigateUrl = "MyReport.csv" When the user clicks the HyperLink I would always like to
4
5574
by: Richard | last post by:
Hi I'm new to ASP/Web programming so any help would be appreciated... Situation: On my web page I would like to present a link {or button} that would allow the user to download a large file. When the user clicks to start the download I would like to display the "Save As" dialog, allow the user to name a place to save the file, and then show the download progress bar while the file downloads Question: How do I make a windows "Save...
0
2983
by: Dune | last post by:
Hi there, I have an aspx page that allows users to enter several parameters using drop downs and text boxes. The users then press a button that produces an extract based on the parameters they entered. When this button is pressed and extract is prduced and IE's standard Open/Save dialog should popup so they can navigate to the directory to save the extract in, or if they want, they can choose to open and view the extract without saving it. ...
4
3698
by: Dorte | last post by:
Hi, I am using the code below to stream a CSV file with the response object. Dim FileName As String = "Test.csv" With Web.HttpContext.Current.Response Web.HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=" & FileName) .Charset = ""
1
1456
by: M Pearson | last post by:
Hello there all, am very new to asp.net programming and am struggling with this problem. What I trying to achieve. On a button click I want the standard web save as dialog to display. The user specifies where to save. I then generate the file which is a series of reports zipped up, which then gets saved to the users pc. The following is some sample code:
4
6270
by: Jonny | last post by:
Hello Group How do I open a Save File Dialog from an ASPX page behind a browse button? Any help would be fantastic!! I am using ASP.NET 1.1 using VB.NET as the coding language TIA
3
6444
by: =?Utf-8?B?YXNkZg==?= | last post by:
Hello. I am making a web application with c# and am using this code: Response.ContentType = "application/x-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("あいうえお") + ".csv"); Encoding encoding = Encoding.GetEncoding("Shift-JIS"); Response.BinaryWrite(encoding.GetBytes(csvStr)); Response.End(); It works fine..the data gets saved nicely to an excel file. The user pushes the...
2
11004
by: vbaDev | last post by:
Hi. I am using Access 2000 and in my code I'm exporting a table into an Excel file (creating it), then the code needs to export another query into the same file (a new worksheet). So I needed both a "Save As" dialog and the ability to grab the filepath so that the second export appends to it. Anyway, I found Microsofts method and it works, except that I can't figure out how to populate the File Name box in the Dialog with a default name (say,...
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9751
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10675
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10749
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7912
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7079
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5740
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5939
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.