Hey there,

I wrote a macro to prompt for the location of a few pictures using
wdDialogFileOpen and insert them into a Word document. It works
great, but now the user is opening this document in an application
that imbeds Word as an OLE object. Now I get run-time error '4605':
This method or property is not available because this document is in
another application."

The code snippet is below; it gives me the error on the first (With
Dialogs) line:

With Dialogs(wdDialogFileOpen)
.Name = "*.jpg; *.gif; *.bmp"
If .Display Then
strFileName = CStr(Trim(WordBasic.FilenameInfo(.Name,
1) & ""))
Else
strFileName = ""
End If
End With

Any suggesstions on how to return control or focus to the document so
I can instantiate the "open dialog" window?

Thanks, C
kaczmar2@msu.edu

Re: "property not available" error in macro by Jezebel

Jezebel
Wed Feb 18 20:44:52 CST 2004

First, how does the enclosing application know that 'Dialogs' refers to a
Word Application dialog? Shouldn't the line be something like With
WordApp.Dialogs(...) ?

Second, if you're just trying to get a filename, why not use a CommonDialog
control and get the name directly, rather than getting Word to do it?






"kaczmar2" <kaczmar2@hotmail.com> wrote in message
news:f8a9b6b8.0402181519.1962cc29@posting.google.com...
> Hey there,
>
> I wrote a macro to prompt for the location of a few pictures using
> wdDialogFileOpen and insert them into a Word document. It works
> great, but now the user is opening this document in an application
> that imbeds Word as an OLE object. Now I get run-time error '4605':
> This method or property is not available because this document is in
> another application."
>
> The code snippet is below; it gives me the error on the first (With
> Dialogs) line:
>
> With Dialogs(wdDialogFileOpen)
> .Name = "*.jpg; *.gif; *.bmp"
> If .Display Then
> strFileName = CStr(Trim(WordBasic.FilenameInfo(.Name,
> 1) & ""))
> Else
> strFileName = ""
> End If
> End With
>
> Any suggesstions on how to return control or focus to the document so
> I can instantiate the "open dialog" window?
>
> Thanks, C
> kaczmar2@msu.edu



Re: "property not available" error in macro by kaczmar2

kaczmar2
Thu Feb 19 07:32:45 CST 2004

I would get the same error if I used something like

oWord.Dialogs() Where oWord was an object of type Word.Application.
I could try the CommonDilog contol, yes, but I think the issue here is
that certan properties are not available when Word in the OLE
container.

C

"Jezebel" <frolly@mkkk.com> wrote in message news:<eXPsXIp9DHA.2524@TK2MSFTNGP11.phx.gbl>...
> First, how does the enclosing application know that 'Dialogs' refers to a
> Word Application dialog? Shouldn't the line be something like With
> WordApp.Dialogs(...) ?
>
> Second, if you're just trying to get a filename, why not use a CommonDialog
> control and get the name directly, rather than getting Word to do it?
>
>
>
>
>
>
> "kaczmar2" <kaczmar2@hotmail.com> wrote in message
> news:f8a9b6b8.0402181519.1962cc29@posting.google.com...
> > Hey there,
> >
> > I wrote a macro to prompt for the location of a few pictures using
> > wdDialogFileOpen and insert them into a Word document. It works
> > great, but now the user is opening this document in an application
> > that imbeds Word as an OLE object. Now I get run-time error '4605':
> > This method or property is not available because this document is in
> > another application."
> >
> > The code snippet is below; it gives me the error on the first (With
> > Dialogs) line:
> >
> > With Dialogs(wdDialogFileOpen)
> > .Name = "*.jpg; *.gif; *.bmp"
> > If .Display Then
> > strFileName = CStr(Trim(WordBasic.FilenameInfo(.Name,
> > 1) & ""))
> > Else
> > strFileName = ""
> > End If
> > End With
> >
> > Any suggesstions on how to return control or focus to the document so
> > I can instantiate the "open dialog" window?
> >
> > Thanks, C
> > kaczmar2@msu.edu