Access data to Excel workbook

Hi

I use Access VBA to export a recordset into an Excel template. I then save the template as a .xls file. Everything works fine except when I open the Excel file the Workbook is hidden. I have to use Menu:Window:Unhide to unhide the workbook.

How can I fix this with VBA from Access

Thx

Code------------------------------------

Set xl = CreateObject("Excel.Application")
Set xlWrkBk = GetObject(FPath & "/FS_Template.xlt")
Set xlsht = xlWrkBk.Worksheets("Window & Exterior Door Schedule")

do the recordset stuff into cells

FName = xl.Application.GetSaveAsFilename
xlWrkBk.SaveAs FileName:=FName

Set xlsht = Nothing
Set xlWrkBk = Nothing
Set xl = Nothing



Answer this question

Access data to Excel workbook

  • Sarguna

    given your code, I believe that

    Set xl = CreateObject("Excel.Application")

    xl.visible=true

    will get the job done.

    HTH

    -Larry-



  • Danny C. McNaught

    Hi

    Thanks for the tip but it still doesn't help. No the Template file Workbook is not hidden. I don't do anything in my code, that I've shown above, except write data to specific cells.

    I have changed my save command to:

    FName = xl.Application.GetSaveAsFilename("Final_Schedule", "Excel Workbook (*.xls), *.xls", , "Final Schedule")
    xlWrkBk.SaveAs FName, xlWorkbookNormal

    I thought the problem might be converting from an .xlt to a .xls but I really don't know.

    Thank again...
    Wayne


  • zdrae

    Hi

    Try activating the window in VBA then use ActiveWindow.Visible = True. Also did you hide the window in the template If not you must have a command in your code which is causing the window to be hidden.


  • Kal100

    Hi...

    This should resolve your issue...

    Dim xlBook as object

    Set xlBook = GetObject("path of the excel template")

    xlBook.Parent.Windows(xlBook.Name).Visible = True

    Cheers!!!

    Karthik



  • Access data to Excel workbook