I am using the below code to copy values from excel and paste into word document and the macro is working fine .
I am facing the issue while doing saveas word documents could you please help me with the code which can saveas the documents in specific folder and close the original document without saving .
Thanks in advance for all the help.
code :
Sub test()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
sDocName = "ABC"
Set objWord =CreateObject("Word.Application")
objWord.Visible =True
objWord.Documents.Open"C:\Users\chandresh.choudhary\Desktop\Word\Format.docx"
WithobjWord.ActiveDocument
.Bookmarks("Text1").Range.Text =ws.Range("B1").Value
.Bookmarks("Text2").Range.Text = ws.Range("B2").Value
.Bookmarks("Text3").Range.Text =ws.Range("B3").Value
End With
Set objWord =Nothing
objWord.SaveAsFilename:="C:\Users\chandresh.choudhary\Desktop\Word\WorkbookName1.Docx"
End Sub
I am facing the issue while doing saveas word documents could you please help me with the code which can saveas the documents in specific folder and close the original document without saving .
Thanks in advance for all the help.
code :
Sub test()
Dim objWord As Object
Dim ws As Worksheet
Set ws = ThisWorkbook.Sheets("Sheet1")
sDocName = "ABC"
Set objWord =CreateObject("Word.Application")
objWord.Visible =True
objWord.Documents.Open"C:\Users\chandresh.choudhary\Desktop\Word\Format.docx"
WithobjWord.ActiveDocument
.Bookmarks("Text1").Range.Text =ws.Range("B1").Value
.Bookmarks("Text2").Range.Text = ws.Range("B2").Value
.Bookmarks("Text3").Range.Text =ws.Range("B3").Value
End With
Set objWord =Nothing
objWord.SaveAsFilename:="C:\Users\chandresh.choudhary\Desktop\Word\WorkbookName1.Docx"
End Sub