Solved

Handling MS-Office Components in VB

Posted on 2002-07-05
5
220 Views
Last Modified: 2010-05-18
I want to have a full control on MS Office Components (Word, Excel) through my VB program. Though one can "execute" external application using
wd as Word.Application
Set wd = new Word.Application
wd.visible = true

but actually it just opens the application in another (external) window, and I want to know whether one can get the Word/Excel application right on the VB form or something similer that can be controlled through VB code (actually i want to control the SAVE, SAVE AS & OPEN feature and rest the things should be handled by Word/Excel itself).

I've seen something similar with WordPad. Its object can be inserted directly on the form. but it is NOT visible on the form during runtime untill doubleclicked on that area, and then it acts just as WordPad on our form, even with all its meus & options except [File] menu.

One more thing, can the document such opened/created through VB form (in word/excel) can be stored "AS IT IS" in any Database(SQL/Oracle)?

My objective is to let the user of my application the facility of WORD/EXCEL within my application and the documents should be stored in database table insted of DOC or XLS file.

Hope somebody's there to help me out!
0
Comment
Question by:vijaywadnere
5 Comments
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7132695
If not XP:
' general declarations section
Private Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long


'form load or after Word was instantiated:

    ' reparent the window to fit our form
    Dim ret As Long
    ret = FindWindow("Opusapp", vbNullString)
    SetParent ret, Me.hWnd
0
 

Author Comment

by:vijaywadnere
ID: 7133703
Richie,
I tried the code supplied by you but it wont work.
I do not understand how FindWindow funciton will come to know about the Word application. I also tried as :

set wd = new Word.Application
dim ret as long
ret = FindWindow( wd.name, vbNullString)
setParent ret, Me.hWnd

but found not running properly. the value returned by the FindWindow in both the cases is "0".

what should be the name of class supplied in FindWindow function? It might have some relation with the word application object, isn't it?
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 7138374
Opussapp is the class name for Word. Wd.name isn't usefull here.
Try this:

set wd = new Word.Application
wd.visible =true
dim ret as long
ret = FindWindow( "Opusapp", vbNullString)
if ret <>0 then
  setParent ret, Me.hWnd
end if

' if you know the name of document in advance, you coul dreplace vbnullstring with "Microsoft Word - " & <document name here>

I used that code a million of times with no problem.
0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7990754
Hi vijaywadnere,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Refund points and save as a 0-pt PAQ.
    *** actual question (control SAVE, etc.) not answered

vijaywadnere, Please DO NOT accept this comment as an answer.
EXPERTS: Post a comment if you are certain that an expert deserves credit.  Explain why.
==========
DanRollins -- EE database cleanup volunteer
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 8053110
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VB error "Type mismatch" 2 51
VBA Word macro - how to get characters after the searched for string 5 69
TT Auto Dashboard 13 85
Child Form in front 4 39
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now