srikanth605
New Member
- Joined
- Oct 23, 2013
- Messages
- 11
Hi,
I have a code to copy the data from excel and paste into word document through book marks.
I am getting error to save the word document in specific folder with the given name in spread sheet.
Sub CopyRangeToWord()
Dim wd As Word.Application
Dim doc As Word.Document
Dim templ As String
Dim srcWkBkName As String
Dim srcWkBk As Workbook
Dim srcRg As String
srcWkBkName = "C:\BB & B\ BB & B SERVICES INC Template Revised.xls"
srcRg = "A1:I20"
Set wd = CreateObject("Word.Application")
wd.Visible = True
templ = "C:\BB & B\ BB & B Services Template.doc"
Set doc = wd.Documents.Add(Template:=templ)
Windows("BB & B SERVICES INC Template Revised.xls").Activate
Sheets("Data").Activate
With doc
doc.Bookmarks("Vendor_cost").Range.Text = Range("A2").Value
doc.Bookmarks("Customer_Number").Range.Text = Range("B2").Value
doc.Bookmarks("Address_Line1").Range.Text = Range("C2").Value
doc.Bookmarks("City_St_and_Zip").Range.Text = Range("D2").Value
doc.Bookmarks("Contact_Name").Range.Text = Range("E2").Value
doc.Bookmarks("Contact_Phone").Range.Text = Range("F2").Value
doc.Bookmarks("Contact_Email").Range.Text = Range("G2").Value
doc.Bookmarks("EMail_Address").Range.Text = Range("H2").Value
End With
ActiveDocument.SaveAs Filename:="C:\BB & B\" & Worksheets("Data").Range("I2").Value, _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub
Please help me.
Thanks,
Sri
I have a code to copy the data from excel and paste into word document through book marks.
I am getting error to save the word document in specific folder with the given name in spread sheet.
Sub CopyRangeToWord()
Dim wd As Word.Application
Dim doc As Word.Document
Dim templ As String
Dim srcWkBkName As String
Dim srcWkBk As Workbook
Dim srcRg As String
srcWkBkName = "C:\BB & B\ BB & B SERVICES INC Template Revised.xls"
srcRg = "A1:I20"
Set wd = CreateObject("Word.Application")
wd.Visible = True
templ = "C:\BB & B\ BB & B Services Template.doc"
Set doc = wd.Documents.Add(Template:=templ)
Windows("BB & B SERVICES INC Template Revised.xls").Activate
Sheets("Data").Activate
With doc
doc.Bookmarks("Vendor_cost").Range.Text = Range("A2").Value
doc.Bookmarks("Customer_Number").Range.Text = Range("B2").Value
doc.Bookmarks("Address_Line1").Range.Text = Range("C2").Value
doc.Bookmarks("City_St_and_Zip").Range.Text = Range("D2").Value
doc.Bookmarks("Contact_Name").Range.Text = Range("E2").Value
doc.Bookmarks("Contact_Phone").Range.Text = Range("F2").Value
doc.Bookmarks("Contact_Email").Range.Text = Range("G2").Value
doc.Bookmarks("EMail_Address").Range.Text = Range("H2").Value
End With
ActiveDocument.SaveAs Filename:="C:\BB & B\" & Worksheets("Data").Range("I2").Value, _
FileFormat:=wdFormatDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub
Please help me.
Thanks,
Sri