Re: Creating a Preview Window in a User Form (Word 2002) by MickeyF
MickeyF
Mon Feb 05 15:16:00 CST 2007
Thank you for the reply Jonathan! That's a great idea I never would have
come up with that on my own. The reason I didn't want to open each document
is because I was afraid of network lag time. The .InsertFile method never
seemed to suffer from that so I was hoping there was a method to capture the
text into a string variable or something rather than just put it in the
document. Seems a little unfair that the makers of Word would use preview
controls in their forms that aren't available to VBA programmers. :)
I'm not sure if I trust my end users with an open dialogue box. I know it
can be limited in scope and type of file to open, but I can't shake the fear
that they'd find SOME way to open up the wrong thing. And generating the
preview in the dialogue box seems to take up quite a bit of time too.
I think I'll try experimenting with opening a document in invisible mode and
see how long that takes and what can be read from an invisible document.
"Jonathan West" wrote:
> Hi Mickey,
>
> Unfortunately, what you want to achieve can't be done. There isn't a preview
> control for UserForms that gives you the same kind of preview as you see in
> the File Open dialog.
>
> The best you can do is actually *use* the File Open dialog.
>
> Under normal circumstances, the FileDialog object would be the best approach
> here, but unfortunately, when you set it to Preview mode, it doesn't display
> the file previews you want.
>
> The File Open dialog that is a member of the Dialogs collection does display
> the preview, but the only way to persuade it to get into preview mode is to
> use SendKeys, which is rather clunky and a method of last resort, but works
> in the particular case
>
> Try this code
>
> With Dialogs(wdDialogFileOpen)
> SendKeys "%l{LEFT}v"
> If .Display = -1 Then
> MsgBox .Name
> Else
> MsgBox "Cancel pressed"
> End If
> End With
>
> --
> Regards
> Jonathan West - Word MVP
> www.intelligentdocuments.co.uk
> Please reply to the newsgroup
>
>
>
>
> "Mickey F." <Mickey F.@discussions.microsoft.com> wrote in message
> news:C4ECFF1C-F038-45FC-BE53-2766A2B3CB74@microsoft.com...
> > Ideally, what I'd like to do is create a UserForm that displays a list of
> > Word docs in a particular directory in a ComboBox. As the user selects
> > different documents in the ComboBox, another Control on the form displays
> > the
> > text of the document, preferably in it's Rich Text Format - but even
> > regular
> > text would be okay. Exactly like how the preview window woks in the
> > AutoText
> > menu.
> >
> > Here's the catch though, I'd like to be able to read from the documents
> > without actually opening them. Sort of like the .InsertFile method, but
> > instead of putting the text into a document, I would want to put that text
> > onto a Control. The text that needs to be previewed from each document
> > WILL
> > be encapsulated in a uniquely named BookMark though.
> >
> > I know how to put the File names into the ComboBox, the part I'm stuck on
> > is
> > being able to read the BookMakrked text from another file WITHOUT opening
> > it
> > (if that's even possible). I would also prefer not having to open a new
> > document or insert anything into the document the UserForm is attached
> > too.
> >
> > Word Version Info: Word 2002 (10.6818.6817) SP 3
>
>
>