Check if specified Excel workbook is already open, with .vbs
Continuing from the title... If it is already open, make it the active window before continuing with script. And if it's not already open, simply open it and continue with script. I have become very confused trying to get this procedure
to happen, this mish-mash is what I have so far:
path=createobject("scripting.filesystemobject").getparentfoldername(wscript.scriptfullname)
excelpath=path&"\example.xlsx"
set objword = createobject("word.application")
set coltasks = objword.tasks
i = 0
for each objtask in coltasks
name = lcase(objtask.name)
If instr(name, "example.xlsx") then
i=1
end if
next
if i=1 then
wscript.echo "An active instance of example.xlsx has been found"
objexcel.visible=true
call CODE
else
set objexcel=createobject("excel.application")
objexcel.workbooks.open(excelpath)
set objsheet=objexcel.activeworkbook.worksheets(1)
objexcel.visible=true
call CODE
end if
sub CODE
objword.quit
wscript.echo "Place rest of code here"
end sub
A running instance of the "example.xlsx" is never detected and made the active window, so the first if block never executes. It always opens a new instance of "example.xlsx". What am I doing wrong? ...I'm a novice at this
so an explanation is appreciated, and if there's an easier way, that too is appreciated.
Spot on, changed the first if condition it to:
if i=1 then
wscript.echo "An active instance of example.xlsx has been found"
set objexcel=getobject(excelpath)
call CODE
...and hey presto, thanks jrv! :D ...By the way, barring the poor indentation and lowercase syntax, is this code a passable attempt at achieving this, or is there a simpler way? And if there's another file named "example" which is not
an excel file, in the task manager running applications list, will it affect the outcome? - Should I add "microsoft excel" to the instr search?
Similar Messages
-
Error message when finalizing...file already open with write protection
I just created my first movie in i Movie. It's about 9 minutes long. When I tried to finalize it it worked for a couple of hours and then came up with a message "unable to prepare project for publishing because an error occurred (file already open with write protection)". What does this mean? I thought I had closed all the files I was using. There was no error number. I tried it 3 times and got the same message. Any thoughts would be greatly appreciated.
AppleMan, I just checked that and it looks like Time Machine isn't open. I checked it by going to finder>applications>R click on time machine. It gave me the option to "open" which makes me think it's already closed. Is there somewhere else I need to be looking?
I made another movie that was just a couple of clips and it finalized fine. On that movie, I had some MTS clips and I converted them to mp4's so iMovie could read them.
In the one that didn't work I did clip one of the movies before I imported it into iMovie. It saved as a .mov instead of a .mp4. Would that make a difference? I checked all of the files and none of them are listed as locked, so I really don't get the "write protected" aspect of this error. -
I have been working for 7 hours today on a major 3-month project. Everything was okay until I closed it and tried to open it. I received this error:
"/Volumes/MediaSAN4/Workbench/HRL /Final Cut Events/Move-In is already open with the same identifier as /Volumes/MediaSAN4/Workbench/HRL /Final Cut Events/Move-In, so the second document cannot be opened.
Move one of these documents out of your Final Cut Events folder. To avoid this problem, copy events from within Final Cut Pro."
not sure what it wants me to do.
When i hit ok EVERY event is gone. all projects say missing event. Even the two I'm not working on. I'm so frustrated I've thought about starting the project over in 7 but I want to stick with it.
I work for a university and have not been able to find help, even from my boss. The only thing I have found to fix it is to dismount the drive (mediasan4) and then remount it and it reconnects everything. But this can't be a good way to work. There are no duplicate events anywhere. there IS for some reason a duplicate mediasan4 drive in the project library, but not under the events library. I have been working in one and everytime I make an edit to my projects in there it makes the changes to the other one. I cannot find a way to delete it. We just reinstalled fcpx a few days ago.
Any and all help is greatly appreciated!Oh yea sorry about that, but yes sir, I sure am. The SAN not the drive. I have tried renaming the event as well. Thanks for checking though.
-
I'm trying to finalize/share to Media Browser a 20 minute still slide show with music and text. I'd like to finalize it 1080 hd and have tried several times, but just before it's finished, a message box pops up saying it can't be done because "File already open with with write permission." What does this mean? All files are closed; this iMovie project is the only thing open. Does it mean one of the song files from iTunes? And should I just settle for saving it as a "large" file, which is what I'm trying right now?
Thanks,
JamieHi
Error -49 opWrErr File already open with write permission
Trash the preference files while application is NOT Running.
from Karsten Schlüter
Some users notice on exporting larger projects from within iMovie that this operation is aborted with an 'error -49'
This issue occours only on MacOs machines using 10.7x
try switching-off the Local Mobile Backup
in Terminal copy/paste
sudo tmutil disablelocal
Re-launch Mac
See also this post
https://discussions.apple.com/thread/4434104?tstart=0
Yours Bengt W -
In Final Cut Pro I was trying to move an Event Library from one hard drive to another as explained in the Help section. After doing so, I received a message that my event is already open with the same identifier as the new one I just created on the new disk. It says the second document cannot be opened and to move one of these documents out of your Final Cut Events folder. It also says to avoid this problem, copy events from within Final Cut Pro, but that is what I did in the first place. What should I do to avoid the double opening conflict?
What exactly are you doing and what version are you using with OS X 10.8?
-
In iMovie I am getting this message...Unable to prepare project for publishing. The project could not be prepared for publishing because an error occurred. File already open with write permission.
How do I resolve this?Hi
Most often it helps by - Turning Off the TimeMachine application - during work in iMovie.
Yours Bengt W -
Why am I suddenly getting this message after I've been using iMovie for a few years now and have never had any such issue before: The project could not be prepared for publishing because an error occurred. (OpWrErr: file already open with with write permission)
Two things
I meant search THIS FORUM
Error minus49 not same as ERROR 49
Yours Bengt W -
Get this message when I try to publish my iMovie project. "unable to prepare project for publishing the project could not be prepared for publishing because an error occurred. (file already open with write permission)"
See the discussion here:
https://discussions.apple.com/message/16784714#16784714 -
When I click on finalize project or when I tried to share on Vimeo iMovie goes through this ten hour operation and the, somethime while I'm away from the computer, I get this error message. UNABLE TO PREPARE PROJECT FOR PUBLISHING. The project could not be prepared for publishing because an error occurred. (File already open with with write permission).
This has happened to me before and I can't nail down the particulars of when this happens. I will say I've never been able to Finalize A Project (not even sure what than means) but I have been able to publish short films to YouTube. This current film is a little over an hour and I picked the HD Format. Could the size have something to do with it?See the discussion here:
https://discussions.apple.com/message/16784714#16784714 -
I HAVE COMPLETED SEVERAL IMOVIES AND FINALIZED JUST FINE. NOW I GET THE FOLLOWING MESSAGE FROM MY LATEST PROJECT. "The project could not be prepared for publishing because an error occurred. (File already open with write permission)"! What is going on?
Hi
Error -49 opWrErr File already open with write permission
Trash the preference files while application is NOT Running.
Easiest way to find out if this is the problem is by:
• Create a new User-Account
• Log out of Your old one and into this
• Re-try iMovie
If it now works OK - then 99.9% the problem is iMovie pref. file that needs to be trashed.
from Karsten Schlüter
Some users notice on exporting larger projects from within iMovie that this operation is aborted with an 'error -49'
This issue occurs only on MacOs machines using 10.7x
try switching-off the Local Mobile Backup
in Terminal copy/paste
sudo tmutil disablelocal
Re-launch Mac
Yours Bengt W -
After attempting to process my movie, I get the following message. "The project could not be prepared for publishing because an error occurred. (OpWrErr: file already open with with write permission). Any ideas what I'm doing wrong?
Hi
Error -49 opWrErr File already open with write permission
Trash the preference files while application is NOT Running.
from Karsten Schlüter
Some users notice on exporting larger projects from within iMovie that this operation is aborted with an 'error -49'
This issue occours only on MacOs machines using 10.7x
try switching-off the Local Mobile Backup
in Terminal copy/paste
sudo tmutil disablelocal
Re-launch Mac
Yours Bengt W -
In Imovie 2011- Trying to image capture my project but it come up after 10 hours of rendering- The project could no be prepared for publishing because an error occured. File already open with write permission. Please Help!
oh and ive tried publishing to almost everything. straight to idvd, to media browser, i tried both hd qualities and also the large quality. no luck with any of those
-
Why am I getting the message "Project could not be prepared because an error occurred. (File already open with write permission.) when trying to
share to the media browser? I have done this many times before and never got this message. This is very frustrating. Can anyone help me?Hi
Error -49 opWrErr File already open with write permission
Trash the preference files while application is NOT Running.
Easiest way to find out if this is the problem is by:
• Create a new User-Account
• Log out of Your old one and into this
• Re-try iMovie
If it now works OK - then 99.9% the problem is iMovie pref. file that needs to be trashed.
from Karsten Schlüter
Some users notice on exporting larger projects from within iMovie that this operation is aborted with an 'error -49'
This issue occurs only on MacOs machines using 10.7x
try switching-off the Local Mobile Backup
in Terminal copy/paste
sudo tmutil disablelocal
Re-launch Mac
Yours Bengt W -
I try to export my Imovie and I always get the error code"Unable to prepare project for publishing...File already open with write permission" it even does it when I am just trying to export to my external hard drive to save the file
Thanks!!! I had same error (with -49) and the mac had an external hard drive attached.. and it was doing a backup. Stopped, disconnected and the project exported!
-
I received a message "OpWrErr: file already open with write permission" when trying to finalize a project in iMovie 11?
Could be a Time Machine error. Try going to the Time Machine Preferences panel and turning off Time Machine. Then try it again. Be sure to turn Time Machine back on when you finish.
Maybe you are looking for
-
HT203175 only a tiny operation screen opens when I start Itunes in Windows Vista
In Windows Vista I am unable to open iTunes (updated 10.7); all that comes up is a small window in top left hand corner which enables me to press start. There is nothing else. It used to work well a few months ago but I downloaded a whole series,
-
I come across that the tablet/pc needes a BIOS Update which automatically began. But that was at 6pm(Puerto Rico Time) and its 10:43pm and its still going. I can not do anything else on the tablet/pc. I bought the tablet/pc online. I got it at the be
-
DB13 error: permission denied
hi all, We want to take backup of our Production server through DB13. but when we start backup it generate error " 11/2/2010 1:15:13 PM Job started 11/2/2010 1:15:13 PM Step 001 started (program RSDBAJOB, variant &0000000000010, user
-
Random seed for the grain in lightroom?
Is it possible to get a random seed for the grain in lightroom when applying to multiple images? I really like the grain in lightroom and would like to use it for an image sequence, so its really important that the grain changes from frame to frame.
-
Taking a web role instance offline
We ran into a mission-critical problem when one of the three web role instances became unresponsive while maintaining the appearance of a healthy instance with the Azure Load Balancer, causing traffic getting directed there and creating an outage. We