Click to See Complete Forum and Search --> : Change Font in NotePad URGENT


guptakvn
August 27th, 2001, 05:46 AM
Dear Gurus,
I am generating reports by flushing the data to a txt file. How can the font in the notepad be modified. the code used for creating file is
filenum = freefile
open filenum for output
data to fill in the file
close filenum
. Please msg me urgently where i can change the font of the txt file being used.

thanks,

Cimperiali
August 27th, 2001, 07:24 AM
Fonts in notepad are managed by notepad: if you set notepad to a different font, it will open all txt files with that font. No way to set this from within a txt file (information is not stored there)...

Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater

Ed_CompSci
September 15th, 2001, 10:02 PM
Sure would be nice if it is possible to change that font from within VB code. You could have an array of forms and then each could bring up Notepad in a different font.


#If Win32 Then
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _
ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd _
As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
#Else
Declare Function ShellExecute Lib "SHELL" (ByVal hwnd%, _
ByVal lpszOp$, ByVal lpszFile$, ByVal lpszParams$, _
ByVal lpszDir$, ByVal fsShowCmd%) As Integer
Declare Function GetDesktopWindow Lib "User" () As Integer
#End If
Private Const SW_SHOWNORMAL = 1

Private Sub cmdOpenTXTFileinNotepad_Click()
Dim Resp
Dim CDR As String * 3
Dim iret As Long
Dim Filenum As Integer
Filenum = FreeFile
Filenum = FreeFile
Open "C:\MyTextFile.txt" For Output As #Filenum 'open a txt file
Print #Filenum, "Hello " & vbCrLf & vbCrLf; "This is a text file created and opened in Visual Basic" & vbCrLf & vbCrLf; "Hope this helps.... "
Close #Filenum 'close the file
Resp = "C:\MyTextFile.txt" 'opens in NOPTEPAD
CDR = "C:\" 'or which drive the file is located
iret = ShellExecute(Me.hwnd, vbNullString, Resp, vbNullString, CDR, SW_SHOWNORMAL)
End Sub

from another thread this shows how to bring up Notepad from a command button.