如何通过VBA在notepad saveas窗口中获取hwnd

时间:2014-08-11 08:07:36

标签: excel vba api csv utf-8

我需要通过VBA代码在记事本中自动调用“saveas”,并选择“encoding”“saveastype” 我可以获得hWnd“Saveas”,但不知道如何获取“编码”组合框的hWnd。 “保存类型”comboBoxo的hWnd

Private Sub Command1_Click()
   Dim hWnd As Long, hMenu As Long, MenuID As Long
   hWnd = FindWindow(vbNullString, "test.txt - Notepad")
   If hWnd > 0 Then
      hMenu = GetMenu(hWnd)
      hMenu = GetSubMenu(hMenu, 0)
      MenuID = GetMenuItemID(hMenu, 3)
      SendMessage hWnd, WM_COMMAND, MenuID, 0&
      SaveAs = FindWindow(vbNullString, "Save As")
      FileNameComboBox = FindWindowEx(ImportBox, 0, "ComboBox", vbNullString)
       SendMessage FileNameComboBox, CB_SHOWDROPDOWN, 4, 0
   End If
End Sub

enter image description here

在上面的代码中,FileNameComboBox是“编码”的hWnd,我不确定 如何获得“另存为类型”组合框

0 个答案:

没有答案