Results 1 to 7 of 7

Thread: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    234

    Resolved Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    That is the first line of my save button. what this does is creates a html file on your desktop, and if there is one already there, it overwrites it!

    now, the problem! this code wont work on onother pc, dew to the path to the desktop being diff on each pc! so lastnight i was refered to some code, it was over a page worth of code, just to determain or get the path to the desktop, it didt work for me, it was for windows ME i think?

    Please tell me there is an easier way? i need to get the desired path, then open the file. if it is to hard to do it this way? what is onother clever way to creat this html file on the desktop?
    Last edited by Triple_access; Jan 16th, 2006 at 01:11 AM.

  2. #2
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    try this,

    VB Code:
    1. Dim PathToDesktop As String
    2.     Set oShell = CreateObject("WScript.Shell")
    3.     PathToDesktop = oShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop")

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    VB Code:
    1. Const CSIDL_DESKTOP = &H0
    2. Const CSIDL_PROGRAMS = &H2
    3. Const CSIDL_CONTROLS = &H3
    4. Const CSIDL_PRINTERS = &H4
    5. Const CSIDL_PERSONAL = &H5
    6. Const CSIDL_FAVORITES = &H6
    7. Const CSIDL_STARTUP = &H7
    8. Const CSIDL_RECENT = &H8
    9. Const CSIDL_SENDTO = &H9
    10. Const CSIDL_BITBUCKET = &HA
    11. Const CSIDL_STARTMENU = &HB
    12. Const CSIDL_DESKTOPDIRECTORY = &H10
    13. Const CSIDL_DRIVES = &H11
    14. Const CSIDL_NETWORK = &H12
    15. Const CSIDL_NETHOOD = &H13
    16. Const CSIDL_FONTS = &H14
    17. Const CSIDL_TEMPLATES = &H15
    18. Const MAX_PATH = 260
    19. Private Type ITEMID
    20.     cb As Long
    21.     abID As Byte
    22. End Type
    23. Private Type ITEMIDLIST
    24.     mkid As ITEMID
    25. End Type
    26. Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" (ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As Long
    27. Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias "SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As Long
    28. Private Sub Form_Load()
    29.     'KPD-Team 1998
    30.     'URL: [url]http://www.allapi.net/[/url]
    31.     'E-Mail: [email][email protected][/email]
    32.     'Set the graphical mode to persistent
    33.     Me.AutoRedraw = True
    34.     'Print the folders to the form
    35.     Me.Print "Start menu folder: " + GetSpecialfolder(CSIDL_STARTMENU)
    36.     Me.Print "Favorites folder: " + GetSpecialfolder(CSIDL_FAVORITES)
    37.     Me.Print "Programs folder: " + GetSpecialfolder(CSIDL_PROGRAMS)
    38.     Me.Print "Desktop folder: " + GetSpecialfolder(CSIDL_DESKTOP)
    39. End Sub
    40. Private Function GetSpecialfolder(CSIDL As Long) As String
    41.     Dim r As Long
    42.     Dim IDL As ITEMIDLIST
    43.     'Get the special folder
    44.     r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
    45.     If r = NOERROR Then
    46.         'Create a buffer
    47.         Path$ = Space$(512)
    48.         'Get the path from the IDList
    49.         r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
    50.         'Remove the unnecessary chr$(0)'s
    51.         GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
    52.         Exit Function
    53.     End If
    54.     GetSpecialfolder = ""
    55. End Function
    Last edited by manavo11; Jan 15th, 2006 at 04:54 PM.


    Has someone helped you? Then you can Rate their helpful post.

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    234

    Re: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    VB Code:
    1. Dim PathToDesktop As String
    2.     Set oShell = CreateObject("WScript.Shell")
    3.     PathToDesktop = oShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop")
    4.    
    5. Open PathToDesktop \ help.html For Output As 1
    6.  
    7. End Sub
    ???????????????

  5. #5
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    Quote Originally Posted by Triple_access
    VB Code:
    1. Dim PathToDesktop As String
    2.     Set oShell = CreateObject("WScript.Shell")
    3.     PathToDesktop = oShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop")
    4.    
    5. Open PathToDesktop \ help.html For Output As 1
    6.  
    7. End Sub
    ???????????????

    VB Code:
    1. Open PathToDesktop & "\help.htm" For Output As #1

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2006
    Posts
    234

    Re: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    hrmmmmm?????

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim PathToDesktop As String
    3.     Set oShell = CreateObject("WScript.Shell")
    4.     PathToDesktop = oShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop")
    5.    
    6. Open PathToDesktop & "\help.htm" For Output As #1
    7.  
    8. Print #1, "HELLO!!!"
    9. Close 1
    10. End Sub

    Works Great!!!!!! THANK YOU, will leave feedback,, great job man!!!!!!!

  7. #7
    Frenzied Member Jmacp's Avatar
    Join Date
    Jul 2003
    Location
    UK
    Posts
    1,959

    Re: Open "C:\Documents and Settings\All Users\desktop\Estamit1.html " For Output As 1

    Quote Originally Posted by Triple_access
    hrmmmmm?????

    VB Code:
    1. Private Sub Command1_Click()
    2. Dim PathToDesktop As String
    3.     Set oShell = CreateObject("WScript.Shell")
    4.     PathToDesktop = oShell.RegRead("HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Desktop")
    5.    
    6. Open PathToDesktop & "\help.htm" For Output As #1
    7.  
    8. Print #1, "HELLO!!!"
    9. Close 1
    10. End Sub

    Works Great!!!!!! THANK YOU, will leave feedback,, great job man!!!!!!!

    glad it worked..

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