Handling HTMLViewer NewWindow (PowerBi)

So, I started a new thing today. Where I work we have a plethora of PowerBi reports scattered around the place, Some in SharePoint but many just in PowerBi with links shared by email. I’m looking at how we can organise them all into a nice structure with either a Desktop or Web App. I started playing around with a desktop app.

I have a window with a HTMLViewer control and a button to load a PowerBi report which I wrote so I know I have access to it.

The (simple redacted) code on the button is:

[code] Dim Page As String

	Page = "https://app.powerbi.com/reportEmbed?reportId=some-report-id-a7bb60bf03ef&autoAuth=true&ctid=some ctid"

When I click the button, I get the PowerBi login page which asks me to Sign-In to PowerBi with a button. Click on that button and I get the NewWindow event, I know that because I have a messagebox.

I found some code that shows embedding the HTMLViewer from the NewWindow event in a Container Control on another window, which I have done but I see nowt. Here is the simple code on the event:

msgbox "New Window" wndLogin.ccLogin.EmbedWithin(Me) wndlogin.show

The window appears but there is nothing in the container control.

I can however load the report if I first log into PowerBi to use the cloud app. I have this in another button that does this:


I cannot do this for users nor do I want to do it by hiding the HTMLViewer during such a LoadURL. I see lots of conversations on MS websites asking for the ability to pass credentials.

I’m sure it’s just my lack of understanding with what/how to handle the NewWindow event. I did see a post which said that all you have to do in the NewWindow event is “Return Me” which should cause the HTMLViewer to display the page you want, but that does not seem to do anything either. I have also seen a couple of posts that indicate that you can get the URL from the CancelLoad event but this event is not fired.

Perhaps it’s a lost cause because of the behaviour of PowerBI but TBH it’s more likely to be my lack of understanding of HTMLViewer as it is a control I have rarely used. If anyone has any pointers in the right direction, I’d be grateful. I did have a quick trawl through the Xojo examples but nothing jumped out at me.



OK, I found a post from 3 years ago which discusses this and gives the TabbedWebBrowser Example. Really Bizarre, I did not find this post yesterday but it was a very long day!