PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
[RESOLVED] AutoGenerating Html Files on a button click-VBForums
Results 1 to 5 of 5

Thread: [RESOLVED] AutoGenerating Html Files on a button click

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    40

    Resolved [RESOLVED] AutoGenerating Html Files on a button click

    hi i am new to this forum.
    i see this is good place to share ideas and ask doubts.
    i have a confusion or a lack of idea ...
    my purpose is to generate a list of html files.
    let me explain it clearly.
    i have some hundreds of jpg files on a folder.
    i want to create individual html files for all those jpg files having that particular jpg file centered in the browser
    sample:
    <html><title>abcd</title>
    <center><img src="folder\abc.jpg"></center>
    </html>

    now i just want to create a vb project which does this job.

    i got a plan of action as
    creating a form with some controls.
    1. selection box for selecting the folder containing the jpg files
    2. command buttong to create a folder inside the parent folder and place the generated html files.
    3. the important thing is the name of the html files should be the same name of the image file.
    for ex: abc.jpg should be generated as abc.html displaying abc.jpg in the center of the browser.
    4. can anyone help me with some ideas.
    code snippets are most welcome.

    my clue: i think redirecting the output to a file and renaming that file as abc.html (where abc is same as in abc.jpg) would be a good idea.
    is there any other good or clear ideas that u can suggest me. !

    thanks in advance
    Last edited by itechlegend; Feb 5th, 2007 at 03:35 AM. Reason: Adding my clue

  2. #2
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: AutoGenerating Html Files on a button click

    put a drive list box, dir list box, file list box, a command button and a text box (for telling the destination for generated file), go to code window and copy the following...





    VB Code:
    1. Private Sub cmdGenerate_Click()
    2.  
    3. For x = 0 To File1.ListCount - 1
    4.     f = FreeFile
    5.     DestPath = IIf(Right(Text1.Text, 1) = "\", Text1.Text, Text1.Text & "\")
    6.     destFileName = Left(File1.List(x), InStrRev(File1.List(x), ".") - 1) & ".html"
    7.     SourcePath = IIf(Right(Dir1.Path, 1) = "\", Dir1.Path, Dir1.Path & "\")
    8.     Debug.Print destFileName
    9.     Open DestPath & destFileName For Output As f
    10.    
    11.     html = "<html><body><center><img src='" & SourcePath & File1.List(x) & "'></img></center></body></html>"
    12.     Print #f, html
    13.     Close
    14.    
    15. Next
    16.  
    17.  
    18.  
    19.  
    20.  
    21. End Sub
    22.  
    23. Private Sub Dir1_Change()
    24. File1.Path = Dir1.Path
    25.  
    26. End Sub
    27.  
    28. Private Sub Drive1_Change()
    29. Dir1.Path = Drive1.Drive
    30.  
    31. End Sub
    32.  
    33. Private Sub Form_Load()
    34. File1.Pattern = "*.jpg;*.gif;*.bmp"
    35.  
    36. End Sub

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    40

    Re: AutoGenerating Html Files on a button click

    oh my god.. gosh..
    wat a fast reply..
    thank u so very much.
    thank u so much.
    let me try it as the first job tomoro morning.
    thanks very much again..
    if i have any doubts i wil post it.

  4. #4
    Frenzied Member moinkhan's Avatar
    Join Date
    Jun 2000
    Location
    Karachi, Pakistan
    Posts
    2,011

    Re: AutoGenerating Html Files on a button click

    yah.... I named command button as cmdGenerate and left every other control have their default names....
    to get this code to work you should name Command Button to cmdGenerate

  5. #5

    Thread Starter
    Member
    Join Date
    Feb 2007
    Posts
    40

    Re: AutoGenerating Html Files on a button click

    thank u so very much moin khan...
    with some changes in the code i got my result
    with 100% success.

    changes i made
    1. i removed the text box for dest path and placed a dir list and folder list
    to make the user more convenient to select the destination path instead of copy pasting or typing the path.
    2. i added all possible image formats for the exe to support all the image formats.
    3. i made simple changes in the html coding for it to generate the way i expect it to.
    4. actually the file name which was generated doesnt seperate with extention.
    for example it generated like "image1html" so i made it to generate as "image1.html"

    alas, the idea helped me a lot.
    thank you so very much once again.
    i am flagging this thread as resolved.
    thanks for your effort.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width