3

I have the following code:

Dim DumpXlApp As Excel.Application = New Excel.Application
Dim DumpWkBk As Excel.Workbook
DumpWkBk = System.Runtime.InteropServices.Marshal.BindToMoniker(FilePath)
DumpXlApp = DumpWkBk.Parent
DumpXlApp.Visible = True

I can't get the DumpWkBk workbook to become visible. Is the issue DumpXlApp = DumpWkBk.Parent line? I don't think it is the BindToMoniker line because I can do things with DumpWkBk.

Ken White
  • 123,280
  • 14
  • 225
  • 444
JoeB
  • 297
  • 4
  • 20
  • What is the value of `FilePath`? It's a full file name path referring to an opened in excel xls file? – Steve Sep 23 '12 at 09:21
  • The filepath is equal to an opened excel file, such as "C:\Temp\Tools\Open Workbook.xlsx". – JoeB Sep 23 '12 at 13:14

1 Answers1

5

I have seen that when BindToMoniker is used in Excel, often the window ends up being hidden. The workbook is still open and accessible to code, it just does not appear in the user interface.

Try also calling this after your other code:

DumpXlApp.Windows(DumpWkBk.Name).visible = true
Daniel
  • 12,982
  • 3
  • 36
  • 60
  • Or just : ´DumpXlApp.Visible = True´ – MaxD May 02 '18 at 08:46
  • @MaxD That might work for you, but it was actually part of the code in the question. I presume that Excel became visible, but not the workbook within Excel. – Daniel May 02 '18 at 13:48