ThisWorkbook.Path for Mac返回(错误68)

我下载了一个电子表格,这个电子表格似乎最初是为windows编写的。 该文件在这里http://www.automateexcel.com/2004/12/15/create_an_rss_feed_with_excel/ 。

对于行RssLocation = ThisWorkbook.Path&“\”&FeedSheet.Cells(5,2).Value

我用“/user/desktop/rsscreate.xlsm”取代了“\”,但是我仍然得到错误。 我也试过“&Application.PathSeparator&”,但仍然是错误。

有什么build议么?

下面是macros的代码。


Sub WriteRss() Dim X As Long Dim FeedSheet As Worksheet Dim RssLocation As String Dim DomainName As String Dim DomainDescription As String Dim DomainTitle As String 'Change the word "Sheet1" to the tabname of 'the sheet where you keep your feeds list Set FeedSheet = Sheets("Sheet1") 'Your domain name(include the http://) DomainName = FeedSheet.Cells(2, 2).Value 'Your Site's Title DomainTitle = FeedSheet.Cells(3, 2).Value 'Your Site's Description DomainDescription = FeedSheet.Cells(4, 2).Value 'Location to write file, defaults to workbook directory RssLocation = ThisWorkbook.Path & "\" & FeedSheet.Cells(5, 2).Value 'Kill the file if it already exists If Len(Dir(RssLocation)) > 0 Then Kill RssLocation End If Open RssLocation For Append As #1 Print #1, "<?xml version=""1.0""" & " encoding=""iso-8859-1""?>" Print #1, "<rss version=" & """" & "2.0" & """" & _ " xmlns:content = ""http:" & _ "//purl.org/rss/1.0/modules/content/"">" Print #1, " <channel>" Print #1, " <title>" & DomainTitle & "</title>" Print #1, " <link>" & DomainName & "</link>" Print #1, " <description>" & DomainDescription & "</description>" Print #1, " <language>en-us</language>" 'Loop through sheet specified 'Start @ row 2 'ColumnA=Title, ColumnB=Link, ColumnC=Description For X = 9 To FeedSheet.Range("A" & FeedSheet.Rows.Count) _ .End(xlUp).Row Print #1, " <item>" Print #1, " <title>" & FeedSheet.Cells(X, 1).Value & _ "</title>" Print #1, " <link>" & FeedSheet.Cells(X, 2).Value & _ "</link>" Print #1, "<description>" Print #1, "<![CDATA[" Print #1, FeedSheet.Cells(X, 3).Value Print #1, " ]]> " Print #1, "</description>" Print #1, " </item>" Next Print #1, " </channel>" Print #1, "</rss>" Close #1 MsgBox "Your new RSS feed can be found here: " & RssLocation End Sub Sub InsertNew() Range("A9:C17").Select Selection.Cut Range("A10:C18").Select ActiveSheet.Paste Range("A18:C18").Select Selection.Copy Range("A9:C9").Select Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, _ SkipBlanks:=False, Transpose:=False Application.CutCopyMode = False End Sub 

编辑:从答案部分添加以下内容。

我在之前的答案中尝试了代码。 If Len(Dir(RssLocation)) > 0我仍然收到错误

任何build议如何可以使用MacId和ThisWorkbook.Path而不是Applcaton.PathSeparator ?. Siddharth你的想法?

试试这个(未经testing)

 RssLocation = ThisWorkbook.Path & "\" & FeedSheet.Cells(5, 2).Value RssLocation = Replace(RssLocation ,"\", Application.PathSeparator) 'Debug.Print RssLocation