Macro help, populating excel spreadsheet

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
 
T

Tom Ogilvy

strLOADate = Cells(16, 2)
strProjectNumber = Cells(6, 2)
strProjectName = Cells(7, 2)
strStage = Cells(31, 2)
set bk = workbooks.Open("C:\MyFolder\Myfile.xls")
set sh = bk.worksheets(1)
Sh.range("A1,B9,C11").Value = strLOADate
sh.Range("A2,B10,C12").Value = strProjectNumber
sh.Range("A3,B11,C13").Value = strProjectname
sh.Range("A4,B12,C14").Value = strStage
 
C

ChrisMattock

That's awesome, thanks but now I need it to creat itself a new folder to
save to based on strProjectNumber...

bk.SaveAs FileName:="C:\LOA\" & strProjectNumber & "\" & fnames$

OK, well obviously the above doesn't work but I am trying to get it to
save as

C:\LOA\ => Then a new folder based on the strProjectName => Then the
filename fnames$ (previously entered from an Input Box (No help needed
with this))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top