|
楼主 |
发表于 2019-12-25 15:36
|
显示全部楼层
不知为何,您给我的代码可以,但又回到了之前的问题,可以在电脑的桌面或电脑本地的其它文件夹里粘贴,就是不能在微信或QQ里粘贴,绝望
我把全部代码都发上来了,由于用的visio 不是excel,所以没有上附件。
Sub 存为PDF()
Dim lshg As String
Dim DiagramServices As Integer
Dim pscode As String
Dim oShellApp, oShellAppWindows, oWin, oWind, Ste, Str, Sty
Ste = ActiveDocument.Path
Str = Left(Ste, Len(Ste) - 1)
Sty = Right(Str, Len(Str) - InStrRev(Str, "\"))
Set oShellApp = CreateObject("Shell.Application")
Set oShellAppWindows = oShellApp.Windows
For Each oWin In oShellAppWindows
For Each oWind In oShellAppWindows
If InStr(1, oWind.locationname, Sty, vbTextCompare) > 0 Then oWind.Quit
Next
If InStr(1, oWin.locationname, Sty, vbTextCompare) > 0 Then oWin.Quit
Next
Set oWin = Nothing
Set oShellApp = Nothing
Set oShellAppWindows = Nothing
DiagramServices = ActiveDocument.DiagramServicesEnabled
ActiveDocument.DiagramServicesEnabled = visServiceVersion140
Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("填充颜色")
On Error Resume Next
Application.ActiveWindow.Page.Shapes.ItemFromID(ActiveWindow.Selection(1).ID).CellsSRC(visSectionObject, visRowFill, visFillForegnd).FormulaU = "THEMEGUARD(RGB(255,255,0))"
On Error Resume Next
Application.ActiveWindow.Page.Shapes.ItemFromID(ActiveWindow.Selection(1).ID).CellsSRC(visSectionObject, visRowFill, visFillBkgnd).FormulaU = "THEMEGUARD(SHADE(FillForegnd,LUMDIFF(THEME(""FillColor""),THEME(""FillColor2""))))"
On Error Resume Next
Application.ActiveWindow.Page.Shapes.ItemFromID(ActiveWindow.Selection(1).ID).CellsSRC(visSectionObject, visRowFill, visFillPattern).FormulaU = "1"
lshg = InputBox("PDF│请输入企业简称:")
If Application.ActivePage.Name = "Hall 8.2" Then
Application.ActiveDocument.ExportAsFixedFormat visFixedFormatPDF, ActiveDocument.Path & "\" & "2020秋季焙烤展_" & Application.ActivePage.Name & " " & lshg & ".pdf", visDocExIntentPrint, visPrintCurrentPage, 3, 3, False, True, True, True, False
Else
Application.ActiveDocument.ExportAsFixedFormat visFixedFormatPDF, ActiveDocument.Path & "\" & "2020BC_Hall " & Application.ActivePage.Name & " " & lshg & ".pdf", visDocExIntentPrint, visPrintCurrentPage, 3, 3, False, True, True, True, False
End If
On Error Resume Next
Application.ActiveWindow.Page.Shapes.ItemFromID(ActiveWindow.Selection(1).ID).CellsSRC(visSectionObject, visRowFill, visFillForegnd).FormulaU = "THEMEGUARD(MSOTINT(RGB(255,255,255),-25))"
On Error Resume Next
Application.ActiveWindow.Page.Shapes.ItemFromID(ActiveWindow.Selection(1).ID).CellsSRC(visSectionObject, visRowFill, visFillBkgnd).FormulaU = "THEMEGUARD(SHADE(FillForegnd,LUMDIFF(THEME(""FillColor""),THEME(""FillColor2""))))"
On Error Resume Next
Application.ActiveWindow.Page.Shapes.ItemFromID(ActiveWindow.Selection(1).ID).CellsSRC(visSectionObject, visRowFill, visFillPattern).FormulaU = "1"
Application.EndUndoScope UndoScopeID1, True
pscode = "powershell $filelist =" & "'" & ActiveDocument.Path & "\" & "2020BC_Hall " & Application.ActivePage.Name & " " & lshg & ".pdf'" & vbCrLf & "$col = New-Object Collections.Specialized.StringCollection " & vbCrLf & "foreach($file in $filelist){$col.add($file)}" & vbCrLf & "Add-Type -AssemblyName System.Windows.Forms" & vbCrLf & "[Windows.Forms.Clipboard]::setfiledroplist($col)"
Shell pscode, vbHide
ActiveDocument.DiagramServicesEnabled = DiagramServices
Shell "Explorer.exe " & ActiveDocument.Path, vbNormalFocus
End Sub
|
|