• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1008
  • Last Modified:

How to use wdDialogFileOpen with default path and default name on the top of the dialog

Hi,

I have implemented the function Vorlageoeffnen, which is attached, in a winword 2003 vba.

My problem:

I want to open the dialog window with a default path which should be the path of the winword application itself. My solution does not work for some reason.

Second:
It would be fine, if i could change the name in the top of the dialog from "Öffnen", or "Open" in English to a diffrent name.

Thanks for any help in advance
Public Function Vorlageoeffnen()
Dim dialOpen As Dialog
Set dialOpen = Dialogs(wdDialogFileOpen)
With dialOpen
'       .Name = Application.ActiveDocument.Path
ChangeFileOpenDirectory (Application.ActiveDocument.Path) & "\"
       .Name = "*.xls"
       .Display
       strExcelDaten = .Name
   
End With
Set doc = Application.ActiveDocument
If dialOpen.Name <> "*.xls" Then
    Ausfuellen
Else
    If doc.ProtectionType = wdNoProtection Then doc.Protect wdAllowOnlyFormFields, NoReset:=True
    Unload frmWarten
    Exit Function
End If
 
End Function

Open in new window

0
rolandkg1001
Asked:
rolandkg1001
1 Solution
 
irudykCommented:
Try using the following code
Public Function Vorlageoeffnen()
 
Dim dialOpen As FileDialog
Set dialOpen = Application.FileDialog(msoFileDialogOpen)
 
With dialOpen
       ChangeFileOpenDirectory (Application.Path) & "\"
       .Title = "Öffnen"
       .ButtonName = "Öffnen"
       .FilterIndex = 2
       .AllowMultiSelect = False
       .InitialFileName = "*.xls"
       .Show
       If .SelectedItems.Count > 0 Then strExcelDaten = .SelectedItems(1)
   
End With
 
Set doc = Application.ActiveDocument
If InStr(1, strExcelDaten, ".xls", vbTextCompare) <> 0 Then
    Ausfuellen
Else
    If doc.ProtectionType = wdNoProtection Then doc.Protect wdAllowOnlyFormFields, NoReset:=True
    Unload frmWarten
    Exit Function
End If
 
End Function

Open in new window

0
 
rolandkg1001Author Commented:
Thanks, that works perfect for me. Your solution is excactly, what I was looking for. Great!
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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now