🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.vbasic
Article #14

"Simple" OLE Automation and Word Problem

#14
From: e... Ed Hassinger
Date: Thu, 25 Sep 1997 00:00
59 lines
2963 bytes
Well, for as praised as OLE automation is, it doesn't appear to do crap.   I have a single form with a single
button with the following code attached to it.




Private Sub Command1_Click()
   Dim oExcelFile As Object
   Set oExcelFile = CreateObject("Word.Application")
   With oExcelFile
        .Documents.Open filename:="C:\win95\desktop\input\yes1.xls", ConfirmConversions:=False,
ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:="",
Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:=""
   End With

End Sub



The purpose of this application is to load an excel file into Word.  Unfortunately, a small dialog with the
caption "Open Worksheet" appears.  The default setting is for all of the Excel sheets, which is what I
want.  However, there does not appear to be any way to hit "return" for this dialog.  Therefore, a user
must hit enter every time the application is run.  (This is bad) 

This should seem possible to do.  Taken verbatim from MS's lame VB help file.  If you select the F2 to get
to the Object Browser, highlight "dialog" on the left, then hit F1 you will get the following help excerpts 
listed below.





"The Dialogs collection contains all the built-in dialog boxes in Word."
"You can display a built-in dialog box to get user input or to control Word by using Visual Basic. "
" To access a particular built-in Word dialog box, you specify a WdWordDialog constant with the
Dialogs property."





According to this, piece of cake.  However, I don't see any WdWordDialog for this "Open Worksheet"
dialog.  The help file did say ALL of Word's dialogs.  Why can't I reach this dialog to do something with
it?  The sheet other available dialogs is about 7 pages long, but there is nothing close in description.

I've tried every other  conceivable way to close this dialog.  The "sendkeys" function does not work. 
Apparently with some kind of DDE and OLE conflict.  Recording a word macro gives me the VB code
above.  However, Word does not include whatever code would be necessary to hit "return" for this
dialog.    Real smart.  I thought part of the purpose of recording a macro would record your keystrokes.  
Apparently not.

I can't use go about this problem with Excel.  And to make sure of any conflicts I have unchecked "ignore
other applications" under TOOLS-OPTIONS-GENERAL (in Excel).

I guess I could go to MS's web page, but that would be like finding a needle in a haystack.  Any advice
would be greatly appreciated.  Please email directly.  Thanks.

Ed Hassinger
Technical Details
Message-ID: <60en02$g7v@news0-alterdial.uu.net>
Path: mbox-mo1.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
From: e...@mdli.com (Ed Hassinger)
Subject: "Simple" OLE Automation and Word Problem
Date: 1997/09/25
Message-ID: <60en02$g7v@news0-alterdial.uu.net>
X-Deja-AN: 275648196
Organization: MDL Information Systems, Inc.
Newsgroups: pl.comp.lang.vbasic
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit