|
-
Aug 15th, 2005, 06:15 AM
#1
[RESOLVED] What Is The .InitDir Equivalent In Word VBA
I have a piece of VBA code (that I got from here) which opens up Word's SaveAs dialog box and blanks out the name of the file so that the user must type in a new file name. The document is a template and I don't want them overlaying it once it gets its Bookmarks populated with data sent to it from my VB screen.
All of that works fine. I submitted my code to our QA department last Thursday, and got back a bug sheet this morning. One of the items on it was that the SaveAs dialog opened in the App.Path of the application (which it is supposed to), and since the Word document is displayed there, there is nothing to prevent the user from simply selecting it as the filename, thus overlaying the template. So, my new spec is to open the SaveAs dialog defaulted to the root of C:\
I know how to do that with a CommonDialog control, but not the Word SaveAs dialog.
What is the equivlent to .InitDir in Word VBA?
-
Aug 15th, 2005, 06:35 AM
#2
Re: What Is The .InitDir Equivalent In Word VBA
Dunno if this is a help or not...
From Help files in word VBA
InitialFileName Property
See AlsoApplies ToExampleSpecificsSet or returns a String representing the path and/or file name that is initially displayed in a file dialog box. Read/write.
expression.InitialFileName
So instead of erasing the whole initial filename (as I think you have from your previous posts) put in the path to show instead with no filename.
I ran a quick test and seems to work.
Feeling like a fly on the inside of a closed window (Thunk!)
If I post a lot, it is because I am bored at work! ;D Or stuck...
* Anything I post can be only my opinion. Advice etc is up to you to persue...
-
Aug 15th, 2005, 07:48 AM
#3
Re: What Is The .InitDir Equivalent In Word VBA
 Originally Posted by Ecniv
Dunno if this is a help or not...
So instead of erasing the whole initial filename (as I think you have from your previous posts) put in the path to show instead with no filename.
I ran a quick test and seems to work. 
Bee-u-tee-ful! Works like a champ. Thanks Ecniv!
VB Code:
Sub FileSaveAs()
On Error GoTo ErrTrap
Dim strFileAs As String
With Application.FileDialog(msoFileDialogSaveAs)
'based on Ecniv post, I changed
.InitialFileName = ""
'to
.InitialFileName = "c:\"
'and it does exactly what I need
.Show
strFileAs = .SelectedItems.Item(1)
End With
ActiveDocument.SaveAs strFileAs
Exit Sub
ErrTrap:
End Sub
Now, it is back to the rest of the list, and then ship back to QA.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|