C
ChrisMattock
Hi all, I have a spreadsheet that uses information from an exce
spreadsheet to open a word document and enter the information a
bookmarks. Then save the document. Now I need -another- button to d
the same but this time open an excel template and populate that usin
the same information, could someone please help, my current code i
below for use with the word document...
Sub main()
strLOADate = Cells(16, 2)
strProjectNumber = Cells(6, 2)
strProjectName = Cells(7, 2)
strStage = Cells(31, 2)
fname$ = InputBox("Save Letter of Acceptance a
PROJECTNUMBER_PROJECTNAME_SUPPLIER_LOA:")
If fname$ = Cancel Then
End ' This will cause the sub to end if the user presses Cancel o
the InputBox
End If
Dim appWD As Word.Application
Set appWD = CreateObject("word.application.8")
appWD.Visible = True
appWD.Documents.Open FileName:="C:\LOA\LOA_Template.doc"
appWD.ActiveDocument.Bookmarks("LOADate").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate2").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate3").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate4").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate5").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate6").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate7").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("Stage").Range = strStage
appWD.ActiveDocument.Bookmarks("ProjectNumber").Range
strProjectNumber
appWD.ActiveDocument.Bookmarks("ProjectNumber2").Range
strProjectNumber
appWD.ActiveDocument.Bookmarks("ProjectNumber3").Range
strProjectNumber
appWD.ActiveDocument.Bookmarks("ProjectName").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName2").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName3").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName4").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName5").Range
strProjectName
appWD.ActiveDocument.SaveAs FileName:="C:\LOA\" & fname$
FileFormat:=wdFormatDocument
appWD.ActiveDocument.Close
appWD.Quit
End Su
spreadsheet to open a word document and enter the information a
bookmarks. Then save the document. Now I need -another- button to d
the same but this time open an excel template and populate that usin
the same information, could someone please help, my current code i
below for use with the word document...
Sub main()
strLOADate = Cells(16, 2)
strProjectNumber = Cells(6, 2)
strProjectName = Cells(7, 2)
strStage = Cells(31, 2)
fname$ = InputBox("Save Letter of Acceptance a
PROJECTNUMBER_PROJECTNAME_SUPPLIER_LOA:")
If fname$ = Cancel Then
End ' This will cause the sub to end if the user presses Cancel o
the InputBox
End If
Dim appWD As Word.Application
Set appWD = CreateObject("word.application.8")
appWD.Visible = True
appWD.Documents.Open FileName:="C:\LOA\LOA_Template.doc"
appWD.ActiveDocument.Bookmarks("LOADate").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate2").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate3").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate4").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate5").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate6").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("LOADate7").Range
Format(strLOADate, "d mmmm yyyy")
appWD.ActiveDocument.Bookmarks("Stage").Range = strStage
appWD.ActiveDocument.Bookmarks("ProjectNumber").Range
strProjectNumber
appWD.ActiveDocument.Bookmarks("ProjectNumber2").Range
strProjectNumber
appWD.ActiveDocument.Bookmarks("ProjectNumber3").Range
strProjectNumber
appWD.ActiveDocument.Bookmarks("ProjectName").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName2").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName3").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName4").Range
strProjectName
appWD.ActiveDocument.Bookmarks("ProjectName5").Range
strProjectName
appWD.ActiveDocument.SaveAs FileName:="C:\LOA\" & fname$
FileFormat:=wdFormatDocument
appWD.ActiveDocument.Close
appWD.Quit
End Su