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
47 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 48

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 48

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

If you work with Word a lot, you probably use styles. If you use styles a lot, you've probably balled your fist more often than not when working with the ribbon. In Word 2007/2010, one of the things that I find missing when using styles is a quic…
I would like to show you some basics you can do with Mailings in MS Word. It´s quite handy feature you can use for creating envelopes, labels, personalized letters etc. First question could be what is this feature good for? Mailing can really he…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …

706 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now