下面的代码可以正常工作,直到生成文件名。它会选择正确的文件夹位置,但文件名为空白。
如果我选择本地计算机上的某个位置,则将显示文件名。你能告诉我我该怎么做吗?
Private Sub CBSaveasPDF_Click()
Dim FileAndLocation As Variant
Dim strPathLocation As String
Dim strFilename As String
Dim strPathFile As String
strPathLocation = "http://teams.xxx.intranet/sites/bipm/test/test/test/test/test/"
strFilename = Me.Range("D8") & " -" & Me.Range("D7") & " -" & Me.Range("J7") & " " & Me.Range("B3")
strPathFile = strPathLocation & strFilename
FileAndLocation = Application.GetSaveAsFilename _
(InitialFileName:=strPathLocation & strFilename, _
filefilter:="PDF Files (*.pdf), *.pdf", _
Title:="Select Folder and FileName to save")
If FileAndLocation = "False" Then
MsgBox ("Document not saved")
Exit Sub
End If
Me.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=strFilename, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True