Results 1 to 5 of 5

Thread: 2 Question - (i) MS Word (ii) Loading time into combo box

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Question

    Hi,

    [1]
    Is it possibble for me to yuse VB and open a MS Word (*.doc) and then save(convert) it to anoth file form, such as RTF or HTML?

    [2]
    I want to load some time in to a combo box (1:00 to 12:00)

    example
    combobox1.additem "1:00"
    combobox1.additem "1:10"
    combobox1.additem "1:20"
    combobox1.additem "1:30"
    combobox1.additem "1:40"
    .... and so on.

    as you can see I want it to go up by 10 mins. What the fastest way to do this.

    Note : If you can only answer one question that's fine

    Thanks



    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

  2. #2
    Fanatic Member
    Join Date
    Oct 2000
    Location
    London
    Posts
    1,008

    Thumbs up Quick one...

    Check out using Word as an object reference - then you can use all of Word's intrinsic commands (inc. saving as RTF). The details are in the Office Visual Basic Programmer Guide.

    Can't remember the details but do a search on VB-World - I hear it is a pretty good site <grin>

    As for adding the time, use a loop with a numeric variable formatted as a time.

    e.g.
    Code:
    Dim t As Variant, tStart As Variant, tNow As Variant
    
    tStart = 1 / 24
    For i = 0 To 66
      t = (1/144) * i
      tNow = tStart + t
      Me.Combo1.AddItem(Format$(tNow, "hh:mm"))
    Next i
    The wierd numbers come from the fact that a second is 1 represents a full day - so a second is 1/86400, a minute is 1/1440 (ten mins is 1/144) and an hour is 1/24.

    Cheers,

    Paul.
    Not nearly so tired now...

    Haven't been around much so be gentle...

  3. #3
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617
    First question is "YES"

    Second Question:: U may want to use the preious suggestion

    For i = 1 To 12
    For x = 0 To 60 Step 10
    ls_string = Str$(i) + ":" & IIf(x < 9, ("0" + Str$(x)), Str$(x))
    Combo1.additem ls_string
    If i = 12 Then Exit For
    Next x
    Next i

  4. #4
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    I'll take a stab at your first question. Use the code below:



    Private Sub WhatEver()

    Dim WordApp As Word.Application

    'Starting Word
    Set WordApp = New Word.Application

    'Open Document
    WordApp.Documents.Open "Document path and filename"
    If Err = 0 Then
    WordApp.ActiveDocument.SaveAs "Document path and name", wdFormatDocument ' or whatever type you want
    If Err = 0 Then
    'Close open documents
    WordApp.Documents.Close wdDoNotSaveChanges
    Else
    ' handle error
    End If
    Else
    ' handle error
    End If


    WordApp.Documents.Close wdDoNotSaveChanges
    WordApp.Application.Quit
    Set WordApp = Nothing

    End Sub

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Oct 1999
    Location
    NY, USA.
    Posts
    240

    Smile Thanks

    Thanks
    Omar
    [email protected]
    http://omar.caribwalk.com
    To God Be The Glory

    I see Tech People ...

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