Bug 126457 - FILEOPEN XLSX VBA macro to switch between active documents does not work
Summary: FILEOPEN XLSX VBA macro to switch between active documents does not work
Status: RESOLVED FIXED
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: BASIC (show other bugs)
Version:
(earliest affected)
6.4.0.0.alpha1+
Hardware: All All
: medium normal
Assignee: Andreas Heinisch
URL:
Whiteboard: target:7.5.0
Keywords:
Depends on:
Blocks: Macro-VBA
  Show dependency treegraph
 
Reported: 2019-07-18 08:13 UTC by NISZ LibreOffice Team
Modified: 2022-11-20 11:04 UTC (History)
4 users (show)

See Also:
Crash report or crash signature:


Attachments
Example file from Excel with the macro (19.81 KB, application/vnd.ms-excel.sheet.macroEnabled.12)
2019-07-18 08:14 UTC, NISZ LibreOffice Team
Details
Example file to open by the macro (14.01 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2019-07-18 08:14 UTC, NISZ LibreOffice Team
Details
Example file to open by the macro (14.02 KB, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet)
2019-07-18 08:14 UTC, NISZ LibreOffice Team
Details
Screenshot of the original document in Calc (103.04 KB, image/png)
2019-07-18 08:15 UTC, NISZ LibreOffice Team
Details

Note You need to log in before you can comment on or make changes to this bug.
Description NISZ LibreOffice Team 2019-07-18 08:13:44 UTC
Description:
Attached example file contains a VBA macro that is supposed to switch the currently activated open file. This does not happen, all we get is a NoSuchElementException.

Steps to Reproduce:
1.	Download the attached files to the c:\TEMP directory
2.	Open the example file and try to run the FileOpenExample macro


Actual Results:
Execution of the macro is stopped at the Activate call.

Expected Results:
The file is activated as in Excel.


Reproducible: Always


User Profile Reset: No



Additional Info:
LibreOffice details:
Version: 6.4.0.0.alpha0+ (x86)
Build ID: 49422a469646ad8be43ba828ca24c2484c26b9e8
CPU threads: 4; OS: Windows 6.3; UI render: default; VCL: win; 
TinderBox: Win-x86@42, Branch:master, Time: 2019-07-08_00:50:19
Locale: hu-HU (hu_HU); UI-Language: en-US
Calc: CL
Comment 1 NISZ LibreOffice Team 2019-07-18 08:14:18 UTC
Created attachment 152845 [details]
Example file from Excel with the macro
Comment 2 NISZ LibreOffice Team 2019-07-18 08:14:34 UTC
Created attachment 152846 [details]
Example file to open by the macro
Comment 3 NISZ LibreOffice Team 2019-07-18 08:14:53 UTC
Created attachment 152847 [details]
Example file to open by the macro
Comment 4 NISZ LibreOffice Team 2019-07-18 08:15:17 UTC
Created attachment 152848 [details]
Screenshot of the original document in Calc
Comment 5 raal 2019-07-21 19:39:52 UTC
Confirm with Version: 6.4.0.0.alpha0+
Build ID: 47a774fbef8c224e4853de3fdd0230b9442bb716
CPU threads: 4; OS: Linux 4.15; UI render: default; VCL: gtk3;
Comment 6 QA Administrators 2021-07-21 03:37:08 UTC Comment hidden (obsolete)
Comment 7 Andreas Heinisch 2022-09-19 18:53:49 UTC
The macro works in excel using:

Public Sub FileOpenExample()
file1 = "C:\temp\Example.xlsx"
file2 = "C:\temp\Example1.xlsx"

Workbooks.Open Filename:=file1
Workbooks.Open Filename:=file2

Windows("Example.xlsx").Activate
Windows("Example1.xlsx").Activate

End Sub

I could not get it to work using your macro:
Public Sub FileOpenExample()
file1 = "C:\temp\Example.xlsx"
file2 = "C:\temp\Example1.xlsx"

Workbooks.Open Filename:=file1
Workbooks.Open Filename:=file2

Windows(file1).Activate
Windows(file2).Activate

End Sub

Did I something wrong?
Comment 8 Commit Notification 2022-11-20 11:03:54 UTC
Andreas Heinisch committed a patch related to this issue.
It has been pushed to "master":

https://git.libreoffice.org/core/commit/deb0bb9f2635a8dfec90b42e3727f4224548a8e9

tdf#126457 - Add URL and workbook name to window titles

It will be available in 7.5.0.

The patch should be included in the daily builds available at
https://dev-builds.libreoffice.org/daily/ in the next 24-48 hours. More
information about daily builds can be found at:
https://wiki.documentfoundation.org/Testing_Daily_Builds

Affected users are encouraged to test the fix and report feedback.