|
Thanks TF
I knew it was interesting, there must be a way as you can do it in Word.
I will give what you have suggested a try and let you know how I get on.
Graham
|
|
|
|
|
Yeah it won't create the new filename for you. Your code actually has to check for a valid file extension and if it's not there, get the selected extension from the SaveFileDialog and append it yourself.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Now this is interesting, below is the code.
If I enter a SaveAs name 'Test' with a filter ext of txt.
Then I get a Test.Text Document (Correct)
but if I use the file name Test.Text with a filter ext of txt.
I get a Test.TEXT File, why?
#Region "Save File"
Private Sub SaveFile(ByVal SaveAs As Boolean)
Dim strExt As String
'If the currentFile already has an ext get it and change it to UpperCase
strExt = System.IO.Path.GetExtension(currentFile).ToUpper()
'Place it in the SFD.Filter
Select Case strExt
Case ".RTF"
SFD.FilterIndex = 1
Case ".TXT"
SFD.FilterIndex = 2
Case ".DOC"
SFD.FilterIndex = 3
Case ".HTML"
SFD.FilterIndex = 4
Case Else
SFD.FilterIndex = 5
End Select
If SaveAs Then
SFD.Title = "QuickWord - SaveAs File"
SFD.DefaultExt = "rtf"
SFD.Filter = "Rich Text Files|*.rtf|Text Files|*.txt|WORD Files|*.doc|HTML Files|*.html|All Files|*.*"
SFD.FileName = currentFile
If SFD.ShowDialog() = Windows.Forms.DialogResult.Cancel Then Exit Sub
If SFD.FileName = "" Then Exit Sub
currentFile = SFD.FileName
Dim exts As String() = SFD.Filter.Split("|")
strExt = exts(SFD.FilterIndex * 2 - 1)
Dim charsToTrim As Char() = {"*"}
Dim trimmedPath As String = strExt.TrimStart(charsToTrim)
strExt = trimmedPath
strExt = strExt.ToUpper()
End If
Select Case strExt
Case ".RTF"
rtbText.SaveFile(currentFile, RichTextBoxStreamType.RichText)
Case ".DOC"
' Copy the contents of the Richtextbox to the clipboard and keep it's formating
Clipboard.SetText(rtbText.Rtf, TextDataFormat.Rtf)
objWord = CreateObject("Word.Application")
objTempDoc = objWord.Documents.Add
With objTempDoc
.Content.Paste()
.SaveAs(currentFile)
End With
objTempDoc.close()
objWord.Quit()
Case Else
Dim txtWriter As System.IO.StreamWriter
txtWriter = New System.IO.StreamWriter(currentFile)
txtWriter.Write(rtbText.Text)
txtWriter.Close()
txtWriter = Nothing
rtbText.SelectionStart = 0
rtbText.SelectionLength = 0
End Select
rtbText.Modified = False
Me.Text = "QuickWord: " & currentFile.ToString()
End Sub
#End Region
-- modified at 16:01 Thursday 8th March, 2007
|
|
|
|
|
I can't tell from the code given. I suspect when you set currentFile something is happening but that code isn't here. Is the value of currentFile coming straight from SFD.FileName or are you doing something to that value before setting currentFile?
|
|
|
|
|
TF
I've modified my last post to save space on the forum, it now contains the complete SaveAs code.
Cheers
Graham
|
|
|
|
|
Hmmm...I just don't see anything there that would cause that to happen. Just for clarification it was the capitalization of TEXT that you had a problem with, right? My only suggestion is step through your code line by line when it saves. Also as your doing that determine if the capitalization is occuring from the dialog itself of it that happens after. Sorry, I just can't see it, but just so you know when I tried it with a savefiledialog I couldn't recreate that problem.
|
|
|
|
|
Thanks TF at least you had a look.
|
|
|
|
|
I'm starting the process of learning/exploring the GDI+, and I have a question about polygons. Is it possible to render/create a multipart polygon. Say for example an outer edge polygon with a hole/island in the middle of it (e.g. a dough nut). Just curious.
Thanks in advance,
David
|
|
|
|
|
Sure. You have to calculate and/or supply all the points, then create the drawing code to "connect the dots".
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
There is an issue that I am still struggling with.
What is the correct technique for calling back to classes in the main .exe from an assembly that is discovered only through reflection, dynamically, at runtime?
I created a sub in the assembly .dll:
Public shared me.host as object
sub initializeassembly(byval host as object)
me.host = host
end sub
and called that sub from the main.
the I called the (public) class in the main from the .dll:
host.subinmain()
However, I find that the class in the main is sometimes disposed of before it is called.
Is it proper to use this technique? What is the alternative? It was suggested to me that I could use an interface, but but I don't see how that really helps, because the name of the class in the main still has to be passed somehow to the .dll
Thanks as always for your time..
|
|
|
|
|
In VB.NET 2005.
I have a button that i want to put an image on (normal bitmap), so i have done via the properties menu, and the image is stored in the resources.
It shows up as being fine in the design view, but when i try to run it, it aint showing up.
Any ideas, i have never used this feature before so i am not sure if i need to do something else??
Cheers all
|
|
|
|
|
HAve you set the Image property?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Hi
1.Can I connect DataBound Controls to Data Control or ADODC at runtime?
2.Can connect DataBound Controls to Database Objects?
Spread wat u Know!
|
|
|
|
|
Are you using VB.NET or VB6? What do you mean by "Database Objects"? Which classes are you talking about?
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Well Im using VB6.
By Database Objects I mean using objects of the classes imported after adding the reference Microsoft DAO 3.6 object library.
Spread wat u Know!
|
|
|
|
|
Cmania wrote: Microsoft DAO 3.6 object library.
Why? That was the last version of DAO Microsoft put out, about 7 years ago (I think!) You might want to move up to something a little more modern and, more importantly, still supported, like ADO.
Better yet, move from VB6 to VB.NET.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Fine!
Wat i exactly wanna no is that whether i can connect DataBound controls to Database Objects of DAO and ADODB library at runtime or not?
I tried but couldnt make it.
If it can be will plz give some code....
To remind u im using VB6.
Spread wat u Know!
|
|
|
|
|
Yes, it's possible. But, I have no examples. I haven't used VB6 in about 6 years now. Examples using DAO are few and far between. If you Google for "VB6 DAO"[^], you'll see some examples, but many problems too.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi,
I want to enable the autorun in pendrive when i insert into my usb port.
By same as CD Autorun
I already tried with autorun.ini and put to pendrive but no use.
Please tell me if anybody knows.......
Thanks & Regards
Kumaran
|
|
|
|
|
This has to be a setting enabled in the O/S. There's nothing you can do in code on the pendrive to enable this functionality.
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Hi dave
Can u tell me what are all the registry entries we have to make for
enable the pendrive automatically.
Thanks & Regards
Kumaran
|
|
|
|
|
I said you couldn't enable it from code autolaunched on the USB key. I didn't say you couldn't enable it at all.
It's amazing what 10 seconds of Googling can find when you type in "autoplay udb drive[^]".
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
disable the TurnoffAutorun in the Group polocies of windows,
Go to Run -> type "gpedit.msc" -> under administrative templaes->system change the setting for turnoffautorun
|
|
|
|
|
|
Yes write an stored procedure and pass path parameter.
If your question is how then plz find below url
http://weblogs.sqlteam.com/tarad/archive/2004/06/16/1607.aspx
Parwej Ahamad
g_parwez@rediffmail.com
|
|
|
|