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

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

jjsanders

New Member
Joined
Oct 16, 2006
Messages
36
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
 

omega66

New Member
Joined
Oct 3, 2006
Messages
9
Sad to say - no. I receive a Compile error: "User-Defined type not defined". Why's that?

Thanks
 

Wolfshead

Board Regular
Joined
Oct 18, 2006
Messages
100
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
 

omega66

New Member
Joined
Oct 3, 2006
Messages
9
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. :)
 

Forum statistics

Threads
1,141,680
Messages
5,707,788
Members
421,527
Latest member
Tamiwsw

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
Top