Solved

Handling MS-Office Components in VB

Posted on 2002-07-05
5
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month6 days, 15 hours left to enroll

623 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