Hi,
I have an export to Word macro. I want to achieve more with is but my skills are limited so if you could help I'd be forever grateful.
The code is below.
Private Sub Quote_Click()
Dim WdObj As Object, fname As String
fname = Sheets(2).[a1].Value
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False
Selection.Copy 'Your Copy Range
WdObj.documents.Add
WdObj.Selection.PasteSpecial Link:=False, _
DataType:=wdPasteText, Placement:= _
wdInLine, DisplayAsIcon:=False
Application.CutCopyMode = False
If fname <> "" Then 'make sure fname is not blank
With WdObj
.ChangeFileOpenDirectory "F:\Aacommon\Joe Signs\Quotes" 'save Dir
.ActiveDocument.SaveAs Filename:=fname & ".doc"
End With
Else:
MsgBox ("File not saved, naming range was botched, guess again.")
End If
With WdObj
.ActiveDocument.Close
.Quit
End With
Set WdObj = Nothing
End Sub
What I would like to achieve is a unique reference number (URN) generated each time the macro button is clicked, that number entered in a specified cell within the sheet and then the file saved as that reference number.
Can anyone help me achieve that?
Also, how would I specify what needs to be exported? For example, I currently have to select the area I want to export and then click the button. I need it to export columns A to J and Rows 1 to 50.
Thanks in advance.
Edit: Apologies for not complying with the rules.
Bookmarks