Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Since Excel and Word seem to be part of the same
MS-Office software set, I assume that Excel can easily be used to open Word??? Just wondering if I can automate Word from the Excel application in any way. thank u |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Yo can do it this way:
Sub test() Dim oWord As Object Dim oDoc As Object Set oWord = CreateObject("Word.Application") oWord.Visible = True End Sub -- Regards! Stefi €˛Robert Crandal€¯ ezt Ć*rta: Since Excel and Word seem to be part of the same MS-Office software set, I assume that Excel can easily be used to open Word??? Just wondering if I can automate Word from the Excel application in any way. thank u . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks Stefi, that works nicely.
I have another question now.....Is there a way to test if Word is already running??? (I mean, if Word is already up and running, then there is no need to create that "Word.Application" object, right??) thank you "Stefi" wrote in message ... Yo can do it this way: Sub test() Dim oWord As Object Dim oDoc As Object Set oWord = CreateObject("Word.Application") oWord.Visible = True End Sub -- |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
' This should help you
Sub Wordhdl() Dim WordApp As Word.Application Dim WordDoc As Word.Document Set WordApp = getWord() Set WordDoc = getDocument(WordApp) ' this will ensure we have an open document End Sub Private Function getWord() As Word.Application On Error Resume Next Err.Clear Set getWord = GetObject(, "Word.Application") If Err.Number < 0 Then ' iff Word isn't there lets start it Set getWord = CreateObject("Word.Application") Err.Clear End If getWord.Visible = msoCTrue End Function Private Function getDocument(WordApp As Word.Application) As Word.Document ' Reference active document On Error Resume Next Set getDocument = WordApp.ActiveDocument If Err.Number < 0 Then 'if no document lets create one Set getDocument = WordApp.Documents.Add() Err.Clear End If End Function |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank you very much. That code seems to be working exactly
as I hoped. I just have one question about the getWord() function. There is a line of code which reads as follows: getWord.Visible = msoCTrue getWord.Visible can only be assigned a True or False value, so what exactly is this "msoCTrue" variable. I tried to Google it, but the results came up with "msoTrue". Is this a typo??? "minimaster" wrote in message ... Private Function getWord() As Word.Application On Error Resume Next Err.Clear Set getWord = GetObject(, "Word.Application") If Err.Number < 0 Then ' iff Word isn't there lets start it Set getWord = CreateObject("Word.Application") Err.Clear End If getWord.Visible = msoCTrue End Function |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel startup | Excel Discussion (Misc queries) | |||
excel startup | Setting up and Configuration of Excel | |||
Excel Startup | Excel Discussion (Misc queries) | |||
Excel Startup | Excel Discussion (Misc queries) | |||
Excel/Word startup: 'Compile error in hidden module: AutoExec' ?? | Excel Discussion (Misc queries) |