Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Download .rtf 3

Status
Not open for further replies.

Pete222

Programmer
Dec 29, 2002
85
0
0
GB
I have a program where, on form load, I want a .rtf file to be downloaded e.g. File.rtf
thanks for any help

Pete.
My site: clix.to/F
 
Not sure what you mean by downloaded, do you want to display an rtf file? If so, use the richtextbox control.
 
what i mean is that when the user opens the program it has a label with a mesage on it from the internet. I don't want a file download box to come up.

all i need to know is how do i download the .rtf file to app.path
i know how to get it from app.path to a label.

Pete.
My site: clix.to/F
 
You could use the Inet Control...

[blue]Dim [/blue]b() [blue]As Byte
[/blue]b() = Inet1.OpenURL(" icByteArray)
[blue]End If

[/blue][green]'Put .rtf to file...
[/green][blue]Dim [/blue]ff [blue]As [/blue]FreeFile
[blue]Open [/blue]App.Path & "\blah.rtf" [blue]For Binary Access Write As [/blue]#ff
[blue]Put [/blue]#ff, , b()
[blue]Close [/blue]#ff
 
Thanks, but it doesn't like Freefile, it says
Compile error:
User-defined type not defined


Pete.
My site: clix.to/F
 
now it comes up with an error on
Open App.Path & "\MC.rtf" For Binary Access Write As #ff
It says bad file name or number

i have changed the URL in the code for the file - it does exist on the web

Pete.
My site: clix.to/F
 
Just tested this ok..

[blue]Private Sub [/blue]Command1_Click()
[blue]Dim [/blue]b() [blue]As Byte
Dim [/blue]ff [blue]As Integer

[/blue]b() = Inet1.OpenURL(" icByteArray)

ff = FreeFile

[blue]Open [/blue]App.Path & "\test.rtf" [blue]For Binary Access Write As [/blue]#ff
[blue]Put [/blue]#ff, , b()
[blue]Close [/blue]#ff
[blue]End Sub
[/blue]


Tek-Tips may add an extra ";" on the end of the url, just delete it
 
Thanks, that works just how i wanted it to.

Pete.
My site: clix.to/F
 
Could probably save a bit of 'egg on face' if you tested before posting....

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Pete, you can also achieve this downloading function with the help of URLDownloadToFile function.

This function is very easy and you don't even need an Inet control if you use this function.
___
[tt]
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (pCaller As Any, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long

Function Download(Url As String, FileName As String) As Boolean
'returns true if successful
Download = URLDownloadToFile(ByVal 0&, Url, FileName, 0, 0) = 0
End Function

Private Sub Form_Load()
[ignore]Download " "C:\tek-tips.htm"[/ignore]
End Sub[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top