Excel VBA 質問スレ Part23at TECH
Excel VBA 質問スレ Part23 - 暇つぶし2ch77:デフォルトの名無しさん
12/02/04 23:20:48.95
>>71
ini ファイルじゃなくて、ブック自体に覚えさせることもできるよ。

Option Explicit
Const PropertyName As String = "SavedFolder"
Sub Macro1()
 Dim SavedFolderProperty As DocumentProperty
 Set SavedFolderProperty = Nothing
 Dim Index As Integer
 With ActiveWorkbook.CustomDocumentProperties
  For Index = 1 To .Count
   If .Item(Index).Name = PropertyName Then
    Set SavedFolderProperty = .Item(Index): Exit For
   End If
  Next
 End With
 With Application.FileDialog(MsoFileDialogType.msoFileDialogSaveAs)
  .FilterIndex = 2
  If SavedFolderProperty Is Nothing Then
   .InitialFileName = ""
  Else
   .InitialFileName = SavedFolderProperty.Value
  End If
  .Show
  If SavedFolderProperty Is Nothing Then
   ActiveWorkbook.CustomDocumentProperties.Add PropertyName, False, MsoDocProperties.msoPropertyTypeString, .SelectedItems.Item(1)
  Else
   SavedFolderProperty.Value = .SelectedItems.Item(1)
  End If
  .Execute
 End With
End Sub


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch