Hoping someone can help me finish this off please.
I have put together some code to automate copying content from a source word file, into excel and carry out some formatting etc. Works exactly as required, all good -
However, I would like to add to the end of the sub, for the save as box to open and prepopulate the filename with the filename from the source word document. A couple of nice to haves with this code would be -
- The output file is automatically saved to .xlsx format (don't need macro enabled)
- The original excel file is the master document with the Macro, so cannot be overwritten or changed, so that its in its original state and ready to be used again the next time automation is required for a new document. I guess then will need code to close original excel file without changes?
- The output file will be saved in a number of subfolders deep, so if there's anyway the save as can auto open to a specific sub folder? Only caveat is the macro will be used by multiple users, so assume the file directory will require some sort of wildcard?
Any thoughts or advice greatly appreciated!
I have put together some code to automate copying content from a source word file, into excel and carry out some formatting etc. Works exactly as required, all good -
Rich (BB code):
Sub QuoteFormat()
Columns("A:A").ColumnWidth = 72.29
Columns("B:D").ColumnWidth = 26.71
Dim WordApp As Object
Dim objDoc As Object
Dim wdFileName As Variant
wdFileName = Application.GetOpenFilename("Word Documents, *.doc*")
If wdFileName = False Then Exit Sub
Set WordApp = CreateObject("Word.Application")
Set objDoc = WordApp.Documents.Open(wdFileName)
WordApp.Selection.WholeStory
WordApp.Selection.Copy
ThisWorkbook.Sheets("Sheet1").Range("A1").Select
ActiveSheet.Paste
objDoc.Close False
WordApp.Quit
Set WordApp = Nothing
Set objDoc = Nothing
Cells.Select
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = False
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
With Selection
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlBottom
.WrapText = True
.Orientation = 0
.AddIndent = False
.IndentLevel = 0
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With
End Sub
However, I would like to add to the end of the sub, for the save as box to open and prepopulate the filename with the filename from the source word document. A couple of nice to haves with this code would be -
- The output file is automatically saved to .xlsx format (don't need macro enabled)
- The original excel file is the master document with the Macro, so cannot be overwritten or changed, so that its in its original state and ready to be used again the next time automation is required for a new document. I guess then will need code to close original excel file without changes?
- The output file will be saved in a number of subfolders deep, so if there's anyway the save as can auto open to a specific sub folder? Only caveat is the macro will be used by multiple users, so assume the file directory will require some sort of wildcard?
Any thoughts or advice greatly appreciated!