2

I'm trying to display MS office files(word,powerpoint,excel) using UIWebview some of the files have macros enable UIWebview is unable to display these files any idea why this happen? is there a way to make UIWebview render these files?.

Note: I do not want the macros to work if i can display the content of the file that will be enough.

1 Answer 1

1

I know this is old, but I ran into it today. It looks UIWebView will NOT open macro-enabled Office files directly. For example, the following code fails -

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:filePath]]];

The code above fails ONLY for macro-enabled Office files - it works just fine for .docx, .pptx, .rtf, .pdf, .txt, etc. files. However, if we pull the file into NSData and then provide the mime type explicitly to UIWebView, the file will open. The code below will open these macro-enabled Office files -

// this will open a .pptm file - replace mime type as necessary for other macro-enabled file types
NSData* fileData = [NSData dataWithContentsOfFile:filePath];
[webView loadData:fileData MIMEType:@"application/vnd.ms-powerpoint.presentation.macroEnabled.12" textEncodingName:nil baseURL:nil];

Tested with .pptm, .ppsm, .potm, .docm, .xlsm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.