Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2007

Tip: Looking for answers? Try searching our database.

converting a file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Curt - 26 Nov 2007 23:01 GMT
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
Graham Mayor - 27 Nov 2007 08:24 GMT
If you saved the rtf file as a Word Document then that's what it now is.

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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
Curt - 27 Nov 2007 21:43 GMT
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

> If you saved the rtf file as a Word Document then that's what it now is.
>
[quoted text clipped - 3 lines]
> > ok. I am useing office 2000.
> > Thanks
Graham Mayor - 28 Nov 2007 07:39 GMT
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")

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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
[quoted text clipped - 37 lines]
>>> with word ok. I am useing office 2000.
>>> Thanks
Curt - 28 Nov 2007 14:02 GMT
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

> 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
[quoted text clipped - 47 lines]
> >>> with word ok. I am useing office 2000.
> >>> Thanks
Graham Mayor - 28 Nov 2007 15:08 GMT
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.

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> appreciate your responce. The path works on file I created
> (yearly)not on converted (yearlya) in same folder also I've learned
[quoted text clipped - 62 lines]
>>>>> with word ok. I am useing office 2000.
>>>>> Thanks
Graham Mayor - 28 Nov 2007 15:12 GMT
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.

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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
[quoted text clipped - 68 lines]
>>>>>> opens with word ok. I am useing office 2000.
>>>>>> Thanks
Curt - 28 Nov 2007 22:20 GMT
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

> 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.
[quoted text clipped - 71 lines]
> >>>>>> opens with word ok. I am useing office 2000.
> >>>>>> Thanks
Graham Mayor - 29 Nov 2007 06:18 GMT
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.

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> both documents are not open at same time. Each is opened from a
> userform seperatly. I have put yearlya into both code areas same
[quoted text clipped - 88 lines]
>>>>>>>> word.dco? It opens with word ok. I am useing office 2000.
>>>>>>>> Thanks
Curt - 29 Nov 2007 19:43 GMT
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?

> 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,
[quoted text clipped - 99 lines]
> >>>>>>>> word.dco? It opens with word ok. I am useing office 2000.
> >>>>>>>> Thanks
Graham Mayor - 30 Nov 2007 13:50 GMT
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)

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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
[quoted text clipped - 113 lines]
>>>>>>>>>> word.dco? It opens with word ok. I am useing office 2000.
>>>>>>>>>> Thanks
Curt - 01 Dec 2007 04:09 GMT
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

> 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
[quoted text clipped - 126 lines]
> >>>>>>>>>> word.dco? It opens with word ok. I am useing office 2000.
> >>>>>>>>>> Thanks
Graham Mayor - 01 Dec 2007 07:09 GMT
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.

Signature

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

My web site www.gmayor.com
Word MVP web site http://word.mvps.org
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>

> 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.
[quoted text clipped - 155 lines]
>>>>>>>>>>>> reconizable word.dco? It opens with word ok. I am useing
>>>>>>>>>>>> office 2000. Thanks
Curt - 01 Dec 2007 18:25 GMT
Will get back when I have time to try this
You knew where and what to look for as I did not.
Thank You

> 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
[quoted text clipped - 201 lines]
> >>>>>>>>>>>> reconizable word.dco? It opens with word ok. I am useing
> >>>>>>>>>>>> office 2000. Thanks
Curt - 12 Dec 2007 15:34 GMT
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


> 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
[quoted text clipped - 126 lines]
> >>>>>>>>>> word.dco? It opens with word ok. I am useing office 2000.
> >>>>>>>>>> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.