尊敬的專家明確名稱檢測,請找我的地方我對着編譯錯誤代碼如下:檢測明確名稱錯誤RangetoHTML = Replace函數。請幫我出去一樣。編譯錯誤:郵件功能
Function RangetoHTML(rng As Range)
Dim fso As Object
Dim ts As Object
Dim TempFile As String
Dim TempWB As Workbook
TempFile = Format(Now, "dd-mm-yy h-mm-ss") & ".htm"
Set x = ActiveWorkbook
Set TempWB = x
Set rng = Nothing
Set rng = ActiveSheet.UsedRange
With TempWB.PublishObjects.Add(_
SourceType:=xlSourceRange, _
Filename:=TempFile, _
Sheet:=TempWB.Sheets(2).Name, _
Source:=TempWB.Sheets(2).UsedRange.Address, _
HtmlType:=xlHtmlStatic)
.Publish (True)
End With
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(TempFile).OpenAsTextStream(1, -2)
RangetoHTML = ts.readall
ts.Close
M= RangetoHTML
RangetoHTML = Replace(M, "align=center x:publishsource=", "align=left x:publishsource=")
''In Above code RangetoHTML for Replace I am facing the error.
Set ts = Nothing
Set fso = Nothing
Set TempWB = Nothing
End Function
這是怎麼涉及到'C++'?如果你的第一件事是'Set rng = Nothing',那麼函數的作用是什麼? –
創建一個本地字符串變量來代替RangeToHTML。在離開函數之前將該變量分配給RangeToHTML。 –
@RichHolton我有** ** **變量來代替** RangetoHTML ** **我已經在我的代碼中更新過了。現在我面臨着**錯誤的參數數量或無效的屬性分配**錯誤。 – sagar