我在Excel2010中编写了以下宏来获取操作按钮,以将给定工作表保存为共享驱动器上的密码保护文件。
- (void)fetchEntries
{
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
[manager GET:API_V3_CHANNEL_URL parameters:nil progress:nil success:^(NSURLSessionTask *task, id responseObject) {
NSDictionary *searchDict = responseObject;
// 541068f7a30379d0d44d6e45
// On filtre le json
NSPredicate *firstNamePredicate = [NSPredicate predicateWithFormat:@"status == %@", @"LIVE"];
NSPredicate *lastNamePredicate = [NSPredicate predicateWithFormat:@"status == %@", @"PAUSE"];
NSPredicate *compoundPredicate = [NSCompoundPredicate orPredicateWithSubpredicates:@[firstNamePredicate, lastNamePredicate]];
self.readArray = [[searchDict objectForKey:@"CONTESTS"] filteredArrayUsingPredicate:compoundPredicate];
NSDate *date = [self.readArray valueForKey:@"drawDate"];
// Delete object with loop (for) or NSPredicate
[self.collectionView reloadData];
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
}
问题是我得到运行时错误'1004'
答案 0 :(得分:1)
我认为这与您的FileName
路径有关。
我测试了它,只是使用了一个链接到我的桌面的路径,它保存得很好。尝试使用指向桌面路径的路径替换相同的测试。
您可能需要将计算机使用的已分配驱动器号添加到网络文件夹路径中。
下面用
更清晰地呈现相同的代码 Private Sub Report_Click()
Sheets("Sheet1").SaveAs _
Filename:="C:\Users\user1\Desktop\" & Sheets("Sheet1").Range("A2"), _
FileFormat:=52, _
Password:="password", _
WriteResPassword:="password", _
ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub
另请参阅此How to programmatically save a file to a network drive in Excel以获取基本示例。