Showing posts with label office-js. Show all posts
Showing posts with label office-js. Show all posts

Friday, August 18, 2017

Unable to add browser in Visual Studio for Office App

Leave a Comment

Using Visual Studio Enterprise 2015 Update 3, I create a new project following these steps:

  • File -> New -> Project -> Templates/Visual C#/ Office/SharePoint/Apps
  • Choose App for Office (.NET Framework 4.5.2)
  • In Create app for Office window, Check Task pane and do Next
  • Check Excel, PowerPoint and Word and click Finish

After creating the solution, In Solution Explorer Window, Select the first project (manifest project) and look at the Properties Window.

If I click the Start Action drop down list, I can only see Chrome and Edge browsers (were installed before visual studio).

I have installed FireFox after visual studio and I'm not unable to add it to Start Action drop down list. I want to debug my Office App in FireFox as well.

How can I fix this issue?

enter image description here

1 Answers

Answers 1

An Office add-in running in desktop Office, which it is where it runs when you are debugging it with Visual Studio on a Windows machine, uses IE under the hood. (For more info, see what-browser-browser-engine-do-office-add-ins-use.) You can't change this. The Start Action setting has no effect. You are always using IE when you press F5. In particular, the Start Action of the manifest project is irrelevant because the manifest doesn't run or get loaded into a browser.

If you want to test the add-in in Office Online, you can sideload it, and when you run it, it will use whatever browser you used to open Office Online.

Read More

Wednesday, April 6, 2016

How to download a file within a TaskPane App without using window.open()?

Leave a Comment

I have an application which shows some static files for download. This application creates an hidden iframe and set the source to the file-url.

The browser shows a save-as dialog.

But within Microsoft Office there is no save-as dialog and the filedownload is not started.

The file is served with Content-Disposition: Attachment. The working solution will simply open a new browser instance and trigger the file download. I don't want to open a new window which will gain focus.

<!DOCTYPE html> <html>     <head>         <script>             function di(){                 document.getElementById("d").src="blob.dat";             }         </script>         <title>download</title>     </head>     <body>         <h1>file loading</h1>         <h2>works</h2>         <p>But opens a new window</p>         <a href="blob.dat" target="_blank"> a blank </a><br>         <a href="blob.dat" target="download"> named frame </a>         <h2>won't work</h2>         <a href="blob.dat"> a self </a><br>         <a href="blob.dat" target="_self"> a self </a><br>         <a href="blob.dat" target="_top"> a top </a><br>         <a href="#" onclick="di();"> iframe </a><br><br>         <iframe id="d"></iframe>     </body> </html> 

I think it is a serius bug, if a web-application is unablle to follow links.

1 Answers

Answers 1

<script language="javascript"> function OpenADocument(strDoc) {          document.blob.hidFLID.value=strDoc;         document.blob.action = "OpenLinksDocument.asp";         document.blob.method="post"         document.blob.submit();  } </script> 

---- ASP Code ----

Private Sub DownloadFile(file, MainFileName)    '--declare variables    Dim strAbsFile    Dim strFileExtension    Dim objFSO    Dim objFile    Dim objStream, FileNM    strAbsFile = Server.MapPath(file)    Set objFSO = Server.CreateObject("Scripting.FileSystemObject")    If objFSO.FileExists(strAbsFile) Then       Set objFile = objFSO.GetFile(strAbsFile)       strFileExtension = LCase(objFSO.GetExtensionName(file))        '-- first clear the response, and then set the appropriate headers       Response.Clear        '-- the filename you give it will be the one that is shown ' to the users by default when they save        dim NewFileName      NewFileName= "RandomFileNameYouWishtoGive" & Session.SessionID &"." &strFileExtension        Response.AddHeader "Content-Disposition", "attachment; filename=" & NewFileName       Response.AddHeader "Content-Length", objFile.Size       Response.ContentType = "application/octet-stream"        Set objStream = Server.CreateObject("ADODB.Stream")       objStream.Open       '-- set as binary       objStream.Type = 1       Response.CharSet = "UTF-8"       '-- load into the stream the file       objStream.LoadFromFile(strAbsFile)       '-- send the stream in the response       Response.BinaryWrite(objStream.Read)       objStream.Close       Set objStream = Nothing       Set objFile = Nothing    Else 'objFSO.FileExists(strAbsFile)       Response.Clear       Response.Write("No such file exists.")    End If    Set objFSO = Nothing End Sub 

-----------------------------------`` Explanation: 1) On You Link page Don't mention Your File name in Anchor tag, 2) instead pass some Encrypted Code or Encrypted File name itself 3) On Page where you are posting File name, Do Form Request for value hidden File ID - hidFLID 4) now use that File name and Add that File name to Response header. 5) This will not show your Actial File Name enter code here`me/File Path 6) Above Example i have specified is in Classic ASP, If you mention your Web - technology, i may help to provide code in that Tech.

Read More

Saturday, March 26, 2016

Add images as multipart/related MIME object to Outlook with Office Js Addin

Leave a Comment

I'm using addFileAttachmentAsync to add an image as an attachment to an email in outlook 2016. Is there a way to specify attachment options? I saw that there is an AttachmentDetail type, can I somehow use this one to specify additional options? My goal is to embed images using multipart/related MIME object.

1 Answers

Answers 1

Inline images don't have great support in the platform right now. We're working on improving this. In the meantime, you can either include <img> tag loading an image from the web, or you can use this code. In OWA, the sender will see an attachment appear in the attachment well and in Outlook, the image won't render for the sender at all. But in both cases the recipient will see a proper inline image.

Office.context.mailbox.item.addFileAttachmentAsync( "http://smartbuildings.unh.edu/wp-content/uploads/2015/06/Winter-Tiger-Wild-Cat-Images-1024x576.jpg", "Winter-Tiger-Wild-Cat-Images-1024x576.jpg", {asyncContext: null}, function (asyncResult)   {   if (asyncResult.status == "failed") {     //showMessage("Action failed with error: " + asyncResult.error.message);   }   else {  Office.context.mailbox.item.body.setSelectedDataAsync(                         "<img src='cid:Winter-Tiger-Wild-Cat-Images-1024x576.jpg'>",                         { coercionType: Office.CoercionType.Html,                          asyncContext: { var3: 1, var4: 2 } },                         function (asyncResult) {                             if (asyncResult.status ==                                  Office.AsyncResultStatus.Failed){                                 showMessage(asyncResult.error.message);                             }                             else {                                 // Successfully set data in item body.                                 // Do whatever appropriate for your scenario,                                 // using the arguments var3 and var4 as applicable.                             }                         });  } }); 
Read More