Starting Word from EXCEL

omega66

New Member
Joined
Oct 3, 2006
Messages
9
Hi guys,

Yet another (most probably) stupid question: is it possible to start WORD from within EXCEL? I know how to operate WORD from EXCEL once WORD is already opened. What I don’t know is - is it possible to launch WORD just by using code in EXCEL?

Thanks guys!
:rolleyes:
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)
Does this help you?

Code:
Private Sub CommandButton1_Click()
   Dim Word As Word.Application
    Dim strMsg As String
    'strMsg = ActiveSheet.Range("B2") & "_" & ActiveSheet.Range("B3")
    strMsg = ThisWorkbook.Sheets("Testformulier").Range("B2") & "_" & ThisWorkbook.Sheets("Testformulier").Range("B3")
    
  ThisWorkbook.Sheets("Testformulier").Range("A2:F28").Copy

  Set Word = New Word.Application
  
On Error GoTo Finally

  
  Word.documents.Open Filename:="T:\temp\test.doc"
  Word.Selection.EndKey Unit:=wdStory
  Word.Selection.TypeParagraph
  Word.ActiveDocument.PageSetup.Orientation = wdOrientLandscape
  Call Word.Selection.PasteSpecial(Link:=False, DataType:=wdPasteOLEObject, _
    Placement:=wdInLine, DisplayAsIcon:=False)
    
  Word.ActiveDocument.SaveAs "T:\temp\" & strMsg & ".doc"
  MsgBox "De file is opgeslagen", vbInformation
  
  
  
Finally:
  Word.Quit
  Set Word = Nothing
End Sub
 
Upvote 0
Sad to say - no. I receive a Compile error: "User-Defined type not defined". Why's that?

Thanks
 
Upvote 0
Hi
You need to set project references to Microsoft Word. From the module select Tools, References, and pick out your version of Word (In my case Microsoft Word 11.0 Object Library

Wolfshead
 
Upvote 0
Hi
You need to set project references to Microsoft Word. From the module select Tools, References, and pick out your version of Word (In my case Microsoft Word 11.0 Object Library

Wolfshead

Thanks Wolf and jjsanders, will do. Back to work for me. :)
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,750
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top