"property not available" error in macro

K

kaczmar2

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
(e-mail address removed)
 
J

Jezebel

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?
 
K

kaczmar2

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
 

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