CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2001
    Posts
    14

    Change Font in NotePad URGENT

    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,




  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Change Font in NotePad URGENT

    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
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Aug 1999
    Location
    California
    Posts
    143

    Re: Change Font in NotePad URGENT

    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.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured