|
-
Nov 1st, 2000, 11:04 AM
#1
Thread Starter
Addicted Member
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
-
Nov 1st, 2000, 11:27 AM
#2
Fanatic Member
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...
-
Nov 1st, 2000, 11:46 AM
#3
Fanatic Member
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
-
Nov 1st, 2000, 11:47 AM
#4
Addicted Member
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
-
Nov 1st, 2000, 12:31 PM
#5
Thread Starter
Addicted Member
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|