VBA 代码

Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Public Sub genHTML()
   Dim HtmlFileName As String
  
   HtmlFileName = ThisWorkbook.Path + "打印凭证.html"
    
   Open HtmlFileName For Output As #1
   
   Print #1, Me.Cells(1, 6)
   
   Close #1
   
  ' open
   Dim Result As Long
    
    Result = ShellExecute(0&, vbNullString, HtmlFileName, vbNullString, vbNullString, vbNormalFocus)
    
    If Result < 32 Then MsgBox "Error"
   
End Sub
原文地址:https://www.cnblogs.com/juking/p/5996837.html