Solved

Handling MS-Office Components in VB

Posted on 2002-07-05
5
223 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2013 combo box not working 3 43
passing a value with stream reader AFTER a ";" 3 66
How to make an ADE file by code? 11 82
VB6 ListBox Question 4 42
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

813 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

18 Experts available now in Live!

Get 1:1 Help Now