converting a file

C

Curt

Have a rtf file saved as a word.doc no good for locate. No matter how I try
to use this file code will not locate file. Is there a way to convert this
file so it is a reconizable word.dco? It opens with word ok. I am useing
office 2000.
Thanks
 
G

Graham Mayor

If you saved the rtf file as a Word Document then that's what it now is.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Curt

What I don't understand is why the following code will not find this file. It
will only find it if I use the complete path from the properties of file.
yearly is a .doc I wrote yearlya is the converted file. Both files a next to
each other in folder. Reason for shorten path is for use on machines that do
not load to C. Want program to look in folder.
Thanks
Private Sub optionbutton35_Click()
OptionButton35.Value = False
Dim Word As New Word.Application
Dim WordDoc As Word.Document
Word.Visible = True
Set WordDoc = Word.Documents.Open("\parade\yearly.doc")
End Sub
Private Sub Optionbutton36_Click()
OptionButton36.Value = False
'Call year
Dim Word As New Word.Application
Dim WordDoc As Word.Document
Set Word = New Word.Application
Word.Visible = True
Set WordDoc = Word.Documents.Open("\parade\yearlya.doc")
Word.Visible = True
end sub
 
G

Graham Mayor

It won't work because you have not told the macro from where to start
looking for the path. . You will need to ensure that your documents are
filed with direct relationship to (say) the Word documents folder and adjust
the relative path to suit in order for the command to find it.
eg
Dim WordDoc As Word.Document
Dim ParadePath As String
ParadePath = Options.DefaultFilePath(wdDocumentsPath)
Set WordDoc = Word.Documents.Open(ParadePath & "\parade\yearly.doc")

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Curt

appreciate your responce. The path works on file I created (yearly)not on
converted (yearlya) in same folder also I've learned that the converted file
was created in office 2003 I am useing 2000 this may be problem.
Thanks Again
 
G

Graham Mayor

I suspect it is more to do with the fact that once you have opened the first
file, while Word remains open, the focus has moved from the default folder
to the folder that contains the first document so that path would need to be
from there or you would have to reset the path to its default before opening
the second document.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Graham Mayor

On further reflection try removing the path from the second document. If it
is opened from the same folder as the first the path will be wrong.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Curt

both documents are not open at same time. Each is opened from a userform
seperatly. I have put yearlya into both code areas same results. Yearly opens
but converted file cannot find. I don't follow how I cam remove the path from
code and have any thing happen.
Will keep experminting
Thanks Again
 
G

Graham Mayor

When you open a document from a location other than the default document
location Word shifts focus to that folder for the purpose of file > open,
until you close Word or until you open a document from another folder.
Without having your document/code to verify, once the first document is
opened then the focus is moved to the folder that contains it. So my
conjecture was that if you change
Set WordDoc = Word.Documents.Open("\parade\yearlya.doc")
to
Set WordDoc = Word.Documents.Open("yearlya.doc")
the document may be found.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Curt

Have tried what you suggested to no avail. I think I've tried every way I can
think of to get it to find this file. on the 27 I did post my code each
routine is opened from a option button on a user form. could the fact that
yearlya was created in a newer version than I am useing be the culprit?
 
G

Graham Mayor

Let's have a re-think. Where exactly are you storing these documents? I can
see they are in a folder called parade, but where are your storing this
folder. e.g. set your install routine to use a specific folder such as a sub
folder of the startup folder. That will give you a start point no matter
where the start folder is locates on a particular pc. This gives you routine
somewhere to search from eg

File1 = Options.DefaultFilePath(wdStartupPath) & "\parade\yearly.doc"
Set WordDoc = Word.Documents.Open(File1)
and
file2 = Options.DefaultFilePath(wdStartupPath) & "\parade\yearlya.doc"
Set WordDoc = Word.Documents.Open(file2)

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Curt

All files for program are in a folder on the desktop called (Parade) path
from properties of folder is C:\Documents and Settings\Curtiss A.
Greer\Desktop
all action takes place inside of folder parade.
A userform with option buttons to open is used to get to the files. The code
posted on the 27 shows code for both option buttons. Not trying to create an
install only open this file.(yearlya) I wrote a mocro in word contolled it
from excel it opened yearly then ran word macro opened yearlya then put
yearly on top. When you closed yearly yearlya was there. What I ened up with
was both files open. Think I am going to walk away till after Christmass.
This program did even with bugs pulled ths Vet's Day Parade out in order. No
one knew till after the parade about the snauff. Sure do appreciate all who
man this forum.
Thanks & Merry Christmass to All
 
G

Graham Mayor

Your choice of a sub folder from the desktop makes the coding required to
obtain the true path rather more complicated, but after doing some digging
on the web, the following does the trick:

Option Explicit

Private Const CSIDL_DESKTOP = &H0
Private Type SHITEMID
cb As Long
abID As Byte
End Type
Private Type ITEMIDLIST
mkid As SHITEMID
End Type
Private Declare Function SHGetSpecialFolderLocation Lib "shell32.dll" _
(ByVal hwndOwner As Long, ByVal nFolder As Long, pidl As ITEMIDLIST) As
Long
Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, ByVal pszPath As String) As
Long

Private Function GetSpecialfolder(CSIDL As Long) As String
Dim r As Long, Path$
Dim IDL As ITEMIDLIST
'Get the special folder
r = SHGetSpecialFolderLocation(100, CSIDL, IDL)
If r = 0 Then
'Create a buffer
Path$ = Space$(512)
'Get the path from the IDList
r = SHGetPathFromIDList(ByVal IDL.mkid.cb, ByVal Path$)
'Remove the unnecessary chr$(0)'s
GetSpecialfolder = Left$(Path, InStr(Path, Chr$(0)) - 1)
Exit Function
End If
GetSpecialfolder = ""
End Function

Sub Test()
Word.Documents.Open (GetSpecialfolder(CSIDL_DESKTOP) & "\parade\yearly.doc")
Word.Documents.Open (GetSpecialfolder(CSIDL_DESKTOP) &
"\parade\yearlya.doc")
End Sub

I take no credit for the producing the code.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
C

Curt

Will get back when I have time to try this
You knew where and what to look for as I did not.
Thank You
 
C

Curt

FYI This may seem strange. I was sure my code was ok. In the end it was.
Problem was a conflick with folder names. For some reason excel was looking
in wrong folder or something. Moved the files into another location together
and now all ok. Thanks for working with me on this one. Now all I need to do
is make an icon out of a picture for the desktop to open. A big Thank You to
All & Merry Christmass to All
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top