Solved

Save word document as docx from user form - want user to be able to browse for file location

Posted on 2016-07-14
3
73 Views
Last Modified: 2016-07-18
Hi Experts,

I'm creating a word macro enabled document (docm) that I want the user to be able to save as a word document (docx) by pressing a button (savecmd) in a userform (saveform). I've got a text box on the form (FileNametxt) where I want them to be able to write the name of the file name that the document will be saved as.

I'd also like to add a feature so they can browse for the best file location where the file will be saved.

Any advice on how I can do this?

Thanks in advance for your help
0
Comment
Question by:martywal
  • 2
3 Comments
 
LVL 50

Expert Comment

by:Rgonzo1971
ID: 41710633
Hi,

why not

Sub SaveMe()
    Set dlgSaveAs = Dialogs(wdDialogFileSaveAs)
    With dlgSaveAs
        .Name = "myDocument" ' suggested name
        .Format = wdFormatXMLDocument
        .Show
    End With
End Sub

Open in new window

0
 
LVL 50

Accepted Solution

by:
Rgonzo1971 earned 500 total points
ID: 41710658
to force docx then use

Sub SaveMeAsDocx()

With Dialogs(wdDialogFileSaveAs)
.Format = wdFormatXMLDocument
If .Display = 0 Then Exit Sub
If .Format = wdFormatXMLDocument Then
    .Execute
Else
   MsgBox ("You are only allowed to save in docx format.  Please try again")
   Call SaveMeAsDocx
End If
End With

Open in new window

0
 

Author Closing Comment

by:martywal
ID: 41718157
Thanks Rgonzo1971, that did just as I was after. Vey helpful! Thx
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question