Please look over the code, something isnt right even though I have compared this to a bunch of posts already. I made comments throughout regarding what is happening where. thank you.
VB Code:
Sub CreateWord() NewBook = ActiveWorkbook.Name 'Obtains the name of the spreadsheet 'This code requires a referece to the Word object model Dim Appword As New Word.Application Dim wdDoc As Word.Document ' What is this for? Set Appword = CreateObject("Word.Application") 'There is a new workbook created called object? Appword.Documents.Add Windows(NewBook).Activate 'Makes sure I stay in the right place for copying from Excel Sheets("CHART").Select For i = 1 To 6 Windows(NewBook).Activate 'Makes sure I stay in the right place for copying from Excel Sheets("CHART").Select CName = "Chart " & i 'Selects the chart to be copied Sheets("Chart").ChartObjects(CName).Activate Sheets("Chart").ChartObjects(CName).Copy MsgBox ("We are on Chart: " & CName) MsgBox (Appword.Name) 'This only says Microsoft Word Appword.Selection.PasteAndFormat wdChartPicture 'Errors and states "command is not available" Next i Appword.Visible = True 'Save New File as : Need to Change File Location information. This is where the newly created file is saved to. ' ChangeFileOpenDirectory _ Drive & Path Appword.ActiveDocument.SaveAs FileName:=FileName & ext, FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False Appword.Documents.Save Appword.Documents.Close '~~~~~~~~~~~~~~~~~~~~~~~~ Windows(NewBook).Activate Sheets("CHART").Select Set Appword = Nothing End Sub




Reply With Quote