Solved

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

Posted on 2008-10-06
2
885 Views
Last Modified: 2012-05-11
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
Comment
Question by:rolandkg1001
2 Comments
 
LVL 23

Accepted Solution

by:
irudyk earned 250 total points
ID: 22682335
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
 

Author Closing Comment

by:rolandkg1001
ID: 31503356
Thanks, that works perfect for me. Your solution is excactly, what I was looking for. Great!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

809 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