Open Word Document
Private Sub CommandButton1_Click()
Dim worddoc As Object
Set worddoc = CreateObject("word.application")
worddoc.Visible = True
worddoc.documents.Open "D:\Pleaseopen.docx"
End Sub
Create Word Document
Private Sub CommandButton1_Click()
Set worddoc = CreateObject("word.application")
worddoc.Visible = True
End Sub
Create Word Document & Save
Private Sub CommandButton1_Click()
'define word application
Dim wapp As Word.Application
Set wapp = CreateObject("word.application")
'create word document
Dim wdoc As Word.Document
Set wdoc = wapp.Documents.Add
wdoc.SaveAs "D:\info"
wdoc.Quit
End Sub
Export from Excel to Word - Single Column
Sub Transfer_from_Excel_To_Word()
Sheets("sheet2").Range("A1:A15").Copy
Dim wordobj As Object
Set wordobj = CreateObject("word.application")
wordobj.Visible = True
Dim worddoc As Object
Set worddoc = wordobj.documents.Open(Filename:="D:\abc.docx")
worddoc.Range.Paste
Application.CutCopyMode = xlCopy
worddoc.Save
worddoc.Close
wordobj.Visible = False
Set wordobj = Nothing
Set worddoc = Nothing
End Sub
Export from Excel to Word - Two Columns
Sub Transfer_from_Excel_To_Word()
Sheets("sheet2").Range("A1:B15").Copy
Dim wordobj As Object
Set wordobj = CreateObject("word.application")
wordobj.Visible = True
Dim worddoc As Object
Set worddoc = wordobj.documents.Open(Filename:="D:\abcd.docx")
worddoc.Range.Paste
Application.CutCopyMode = xlCopy
worddoc.Save
worddoc.Close
wordobj.Visible = False
Set wordobj = Nothing
Set worddoc = Nothing
End Sub