Corticus
Well-known Member
- Joined
- Apr 30, 2002
- Messages
- 1,579
Hi all!
I am using the following code to convert and XL spreadsheet to a Word document.
Currently the filename is determined from user-input in an inputbox. I removed the input box code for clarity.
All I want to do is use a save as dialog box to pick what I save the file as, instead of "fname" which gets its value from an input box.
Word's code for this dialog box is:
but this won't execute in Excel.
I could really use this macro if I could get it a little more user-friendly, I've got about six different versions I'm playing with, this is the most promising...
Thanks all,
Corticus
I am using the following code to convert and XL spreadsheet to a Word document.
Currently the filename is determined from user-input in an inputbox. I removed the input box code for clarity.
Code:
Sub WordUpEdit()
'saves selected range as Word file
Dim WdObj As Object, fname As String
Dim test As Variant
On Error GoTo Errorchecker
'creates Word object
Set WdObj = CreateObject("Word.Application")
WdObj.Visible = False
'copies data
Selection.Copy
WdObj.documents.Add
'this line specifies to paste special, as Unicode text
WdObj.Selection.PasteSpecial Link:=False, DataType:=20, Placement:=wdInLine, DisplayAsIcon:=False
'I would like to get fname from the save as dialog box
With WdObj
.ActiveDocument.SaveAs Filename:=fname & ".doc"
.ActiveDocument.Close
.Quit
End With
Set WdObj = Nothing
Range("A1").Select
Exit Sub
Errorchecker:
Select Case Err.Number
Case 4198
MsgBox ("Please select range to copy!")
Range("A1").Select
Case Else
MsgBox ("Operation Failed...sorry!")
End Select
End Sub
All I want to do is use a save as dialog box to pick what I save the file as, instead of "fname" which gets its value from an input box.
Word's code for this dialog box is:
Code:
Application.Dialogs(wdDialogFileSaveAs).Show
but this won't execute in Excel.
I could really use this macro if I could get it a little more user-friendly, I've got about six different versions I'm playing with, this is the most promising...
Thanks all,
Corticus