не работает filedialog в outlook

Программирование на Visual Basic for Applications
yyyy
Начинающий
Начинающий
 
Сообщения: 10
Зарегистрирован: 28.10.2005 (Пт) 7:41

не работает filedialog в outlook

Сообщение yyyy » 02.11.2005 (Ср) 17:07

Почему такой код в outlook'е:
Sub ShowSaveAsDialog()
Dim dlgSaveAs As FileDialog
Set dlgSaveAs = Application.FileDialog(FileDialogType:=msoFileDialogSaveAs)
dlgSaveAs.Show
End Sub
выдает ошибку: объект не поддерживает данный метод?
Попробовала в excel - все нормально открывается.
Сравнила все refrences'ы в tools'ах.
В чем ошибка?

Спасибо.

GSerg
Шаман
Шаман
 
Сообщения: 14286
Зарегистрирован: 14.12.2002 (Сб) 5:25
Откуда: Магадан

Сообщение GSerg » 02.11.2005 (Ср) 17:10

В том, что excel.application и outlook.application - разные вещи.
Как только вы переберёте все варианты решения и не найдёте нужного, тут же обнаружится решение, простое и очевидное для всех, кроме вас

yyyy
Начинающий
Начинающий
 
Сообщения: 10
Зарегистрирован: 28.10.2005 (Пт) 7:41

Сообщение yyyy » 02.11.2005 (Ср) 17:13

нет ну пример то из outlook'a
и вообщем какая разница, код то одинаковый или я
ошибаюсь?
если ошибаюсь, то как вызвать диалог в outlook'e?

GSerg
Шаман
Шаман
 
Сообщения: 14286
Зарегистрирован: 14.12.2002 (Сб) 5:25
Откуда: Магадан

Сообщение GSerg » 02.11.2005 (Ср) 17:38

yyyy писал(а):вообщем какая разница, код то одинаковый

"Я пыталась жарить яичницу в холодильнике. Однако яйца не пожарились, а замёрзли. Я проверила: холодильник и плита одной и той же фирмы.
В чём ошибка?"


http://bbs.vbstreets.ru/viewtopic.php?p=23532#23532
http://bbs.vbstreets.ru/viewtopic.php?p=46932#46932
http://bbs.vbstreets.ru/viewtopic.php?p=7957#7957
Как только вы переберёте все варианты решения и не найдёте нужного, тут же обнаружится решение, простое и очевидное для всех, кроме вас

yyyy
Начинающий
Начинающий
 
Сообщения: 10
Зарегистрирован: 28.10.2005 (Пт) 7:41

Сообщение yyyy » 02.11.2005 (Ср) 19:07

Спасибо за ссылки. И все-таки риторический вопрос:
зачем в справке outlook'a приведен такой код? Я понимаю,
что справка по vba, но все-таки сильно вводит в заблуждение
такого чайника как я.

GSerg
Шаман
Шаман
 
Сообщения: 14286
Зарегистрирован: 14.12.2002 (Сб) 5:25
Откуда: Магадан

Сообщение GSerg » 02.11.2005 (Ср) 19:18

Где именно в справке аутлука приведён такой код?
Как только вы переберёте все варианты решения и не найдёте нужного, тут же обнаружится решение, простое и очевидное для всех, кроме вас

yyyy
Начинающий
Начинающий
 
Сообщения: 10
Зарегистрирован: 28.10.2005 (Пт) 7:41

Сообщение yyyy » 03.11.2005 (Чт) 4:06

если в среде VBA outlook'a в справке по VB сделать поиск
FileDialog, она возвращает, что FileDialog - это объект (причем
в скобках указано, что имеет отношение к office, а не к excel)
и код (можешь,конечно, сам найти, но я на всякий случай):

Provides file dialog box functionality similar to the functionality of the standard Open and Save dialog boxes found in Microsoft Office applications. With these dialog boxes, users of your solutions can easily specify the files and folders that your solution should use.
Using the FileDialog object
Use the FileDialog property to return a FileDialog object. The FileDialog property is located in each individual Office application's Application object. The property takes a single argument, DialogType, that determines the type of FileDialog object that the property returns. There are four types of FileDialog object:
Open dialog box - lets users select one or more files that you can then open in the host application using the Execute method.
SaveAs dialog box - lets users select a single file that you can then save the current file as using the Execute method.
File Picker dialog box - lets users select one or more files. The file paths that the user selects are captured in the FileDialogSelectedItems collection.
Folder Picker dialog box - lets users select a path. The path that the user selects is captured in the FileDialogSelectedItems collection.
Each host application can only instantiate a single instance of the FileDialog object. Therefore, many of the properties of the FileDialog object persist even when you create multiple FileDialog objects. Therefore, make sure that you've set all of the properties appropriately for your purpose before you display the dialog box.
In order to display a file dialog box using the FileDialog object, you must use the Show method. Once a dialog box is displayed, no code will execute until the user dismisses the dialog box. The following example creates and displays a File Picker dialog box and then displays each selected file in a message box.
Sub Main()
'Declare a variable as a FileDialog object.
Dim fd As FileDialog
'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)
'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant
'Use a With...End With block to reference the FileDialog object.
With fd
'Use the Show method to display the File Picker dialog box and return the user's action.
'The user pressed the action button.
If .Show = -1 Then
'Step through each string in the FileDialogSelectedItems collection.
For Each vrtSelectedItem In .SelectedItems
'vrtSelectedItem is a String that contains the path of each selected item.
'You can use any file I/O functions that you want to work with this path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem
Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With
'Set the object variable to Nothing.
Set fd = Nothing
End Sub

GSerg
Шаман
Шаман
 
Сообщения: 14286
Зарегистрирован: 14.12.2002 (Сб) 5:25
Откуда: Магадан

Сообщение GSerg » 03.11.2005 (Чт) 12:21

:?
Чё-то не так...
То ли я туплю, то ли MS :)
Как только вы переберёте все варианты решения и не найдёте нужного, тут же обнаружится решение, простое и очевидное для всех, кроме вас

ntt
Начинающий
Начинающий
 
Сообщения: 1
Зарегистрирован: 10.07.2014 (Чт) 10:02

Re: не работает filedialog в outlook

Сообщение ntt » 10.07.2014 (Чт) 10:04

Код: Выделить всё
Public Sub TestFileDialog()
    Dim otherObject As Excel.Application
    Dim fdFolder As office.FileDialog

    Set otherObject = New Excel.Application
    otherObject.Visible = False
    Set fdFolder = otherObject.Application.FileDialog(msoFileDialogFolderPicker)
    fdFolder.Show
    Debug.Print fdFolder.SelectedItems(1)
    otherObject.Quit
    Set otherObject = Nothing
End Sub

Viper
Артефакт VBStreets
Артефакт VBStreets
Аватара пользователя
 
Сообщения: 4394
Зарегистрирован: 12.04.2005 (Вт) 17:50
Откуда: Н.Новгород

Re: не работает filedialog в outlook

Сообщение Viper » 13.07.2014 (Вс) 12:47

Почти 10 лет прошло, какой смысл размещения кода?
Весь мир матрица, а мы в нем потоки байтов!

Qwertiy
Доктор VB наук
Доктор VB наук
 
Сообщения: 2753
Зарегистрирован: 26.06.2011 (Вс) 21:26

Сообщение Qwertiy » 14.07.2014 (Пн) 14:06

Эм.. Мы тут что, запускаем целый Excel ради того, чтобы показать диалог сохранения файла :shock: ?


Вернуться в VBA

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 9

    TopList  
cron