Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Worksheet Functions / June 2007

Tip: Looking for answers? Try searching our database.

How to open a new instance of Word and its .doc file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Launchnet - 18 Jun 2007 00:40 GMT
Here I am back with another question.

I need an Excel Macro that will open "MS Word" with a blank document shown.

Secondly, I need an Excel Macro that will open "MS Word with a "Named.doc"

Please see the two codes I have tried.  Both will open Word, but neither will
display a blank document or a "Named.doc"

I copied the following ideas from 2 Macro's received so thankfully from  Bob.

Sub NewWordOnly()
Dim oXL As Object
  Set oXL = CreateObject("Word.Application")
  oXL.Visible = True
  oXL.BlankDocument.Add
End Sub

Sub NewWordWithDocument()
Dim oMS As Object
Dim oWD As Object

  Set oMS = CreateObject("Word.Application")
  oMS.Visible = True
  Set oWD = oXL.BlankDocument.Open("C:\documents and settings\default\my
documents\travelagent.doc")
End Sub

Signature

Please take a look at  www.openoursite.com  Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story.  God Bless for everyones help.

Bernie Deitrick - 18 Jun 2007 15:01 GMT
Sub NewWordOnly2()
Dim oWordApp As Object
  Set oWordApp = CreateObject("Word.Application")
  oWordApp.Visible = True
  oWordApp.Documents.Add DocumentType:=wdNewBlankDocument
End Sub

Sub NewWordWithDocument2()
Dim oWordApp As Object
Dim oWordDoc As Word.Document

  Set oWordApp = CreateObject("Word.Application")
  oWordApp.Visible = True
  Set oWordDoc = oWordApp.Documents.Open( _
   "C:\documents and settings\default\my documents\travelagent.doc")
End Sub

HTH,
Bernie
MS Excel MVP

> Here I am back with another question.
>
[quoted text clipped - 23 lines]
> documents\travelagent.doc")
> End Sub
Launchnet - 18 Jun 2007 18:11 GMT
Hi Bernie . . .
Have both codes working.  I had to change . . . Dim oWordDoc As Word.Document
to   Dim oWordDoc As Object on second code (Sub NewWordWithDocument2()
Thanks very very much.

Bernie . . . If you are 30 or over, please read my story in
www.openoursite.com
Select:  "Keywords"          Then, Select:  "Matt's Story"  It can save your
life.  My near perfect 1961 Red Chrysler 300 is on the front page of the site.

Again, many thanks.  I'm doing my best for a 74 year old to learn, and it's
coming.

Matt @ Launchnet

>Sub NewWordOnly2()
>Dim oWordApp As Object
[quoted text clipped - 22 lines]
>> documents\travelagent.doc")
>> End Sub

Signature

Please take a look at  www.openoursite.com  Click on: "Keywords" and then
Click on "Matt's Story" and if you are a man, you should be very happy that
you read my story.  God Bless for everyones help.

Bernie Deitrick - 18 Jun 2007 18:20 GMT
Matt,

If you set a reference to MS Word, then the dimming of oWordDoc would work...  I forgot to state
that, just assuming that you would have it already...

HTH,
Bernie
MS Excel MVP

> Hi Bernie . . .
> Have both codes working.  I had to change . . . Dim oWordDoc As Word.Document
[quoted text clipped - 37 lines]
>>> documents\travelagent.doc")
>>> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.