block.docx when opening *.doc file?

J

jodleren

Hi all!

My client moved to the new office 2009 or vista - the ugly version
with the impossible new menus.
Now, when editing files, when opening it always pops up that
"blocks.docx" blabla and they can select "edit, read only or so"
The point is that the file is a system file I asume, it happens when
word is open with another file, and I open my file (no not that one
above). The file I create is always new, a copy of a "template" where
I should replace some text.
Then is asks what to do with the blocks.docx when I open
"projectnew.doc".

It works with office xp and all.

My code:

try
if VarIsEmpty(WordApplication) then
WordApplication := CreateOleObject('Word.Application');
//WordApplication.Visible := True; {enable this line for
debugging}
WordApplication.DisplayAlerts := wdAlertsNone; // **** this
should take it out???? *****
WordApplication.Documents.Open(ExtractFilePath(ParamStr(0)) +
TempFile); // ******* it happens here! ******
Hwnd := FindWindow('OpusApp', PChar('Microsoft Word - ' +
ExtractFileName(TempFile)));

TempStr := '17';
WordApplication.ActiveDocument.Content.Find.Execute(FindText :=
'¤offerno¤', ReplaceWith := TempStr);
WordApplication.ActiveDocument.Save;
finally
if not VarIsEmpty(WordApplication) then
begin
WordApplication.ActiveDocument.Saved := True;
WordApplication.Quit;
end;
end;
 
G

Graham Mayor

It helps if you quote the exact system message text. However I assume that
this is a reference to the Building Blocks.dotx template, which as you
suggest will be in use if Word is already open when you run your process to
create another Word instance. Instead of creating another Word instance,
check to see if Word is already open and if it is, use the current instance
in which to run your process.

In vba maybe something like

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open("D:\path\docname.docx")


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


Hi all!

My client moved to the new office 2009 or vista - the ugly version
with the impossible new menus.
Now, when editing files, when opening it always pops up that
"blocks.docx" blabla and they can select "edit, read only or so"
The point is that the file is a system file I asume, it happens when
word is open with another file, and I open my file (no not that one
above). The file I create is always new, a copy of a "template" where
I should replace some text.
Then is asks what to do with the blocks.docx when I open
"projectnew.doc".

It works with office xp and all.

My code:

try
if VarIsEmpty(WordApplication) then
WordApplication := CreateOleObject('Word.Application');
//WordApplication.Visible := True; {enable this line for
debugging}
WordApplication.DisplayAlerts := wdAlertsNone; // **** this
should take it out???? *****
WordApplication.Documents.Open(ExtractFilePath(ParamStr(0)) +
TempFile); // ******* it happens here! ******
Hwnd := FindWindow('OpusApp', PChar('Microsoft Word - ' +
ExtractFileName(TempFile)));

TempStr := '17';
WordApplication.ActiveDocument.Content.Find.Execute(FindText :=
'¤offerno¤', ReplaceWith := TempStr);
WordApplication.ActiveDocument.Save;
finally
if not VarIsEmpty(WordApplication) then
begin
WordApplication.ActiveDocument.Saved := True;
WordApplication.Quit;
end;
end;
 
J

jodleren

It helps if you quote the exact system message text. However I assume that
this is a reference to the Building Blocks.dotx template, which as you
suggest will be in use if Word is already open when you run your process to
create another Word instance. Instead of creating another Word instance,
check to see if Word is already open and if it is, use the current instance
in which to run your process.

In vba maybe something like

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open("D:\path\docname.docx")

Would it be possible to hide the activeDocument here?


WordApplication.ActiveDocument.Hidden := _true; ?
WordApplication.ActiveDocument.Visible := False; ?

WBR
Sonnuch
 
J

jodleren

It helps if you quote the exact system message text. However I assume that
this is a reference to the Building Blocks.dotx template, which as you
suggest will be in use if Word is already open when you run your process to
create another Word instance. Instead of creating another Word instance,
check to see if Word is already open and if it is, use the current instance
in which to run your process.

I havent been able to recreate the situation at all...
I really wonder what can cause it


Sonnich
 
G

Graham Mayor

Do you mean as in the example

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open("D:\path\docname.docx")
wdApp.Visible = False
MsgBox wdApp.ActiveDocument.Name
wdDoc.Close
wdApp.Quit


--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>


It helps if you quote the exact system message text. However I assume that
this is a reference to the Building Blocks.dotx template, which as you
suggest will be in use if Word is already open when you run your process
to
create another Word instance. Instead of creating another Word instance,
check to see if Word is already open and if it is, use the current
instance
in which to run your process.

In vba maybe something like

Dim wdApp As Word.Application
Dim wdDoc As Word.Document
On Error Resume Next
Set wdApp = GetObject(, "Word.Application")
If wdApp Is Nothing Then Set wdApp = CreateObject("Word.Application")
Set wdDoc = wdApp.Documents.Open("D:\path\docname.docx")

Would it be possible to hide the activeDocument here?


WordApplication.ActiveDocument.Hidden := _true; ?
WordApplication.ActiveDocument.Visible := False; ?

WBR
Sonnuch
 
J

jodleren

wdApp.Visible = False will hide the app, I want to hide my newly
opened doc - it pops up, so I can hide it by hiding the app - but
there are other documents there :)
 
G

Graham Mayor

wdApp.Visible = False will hide the app, I want to hide my newly
opened doc - it pops up, so I can hide it by hiding the app - but
there are other documents there :)

OK change
wdApp.quit
to
wdApp.Visible = True

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
J

jodleren

Hello

Still not what I need

I found this:

WordApplication.ActiveDocument.ActiveWindow.Visible := False;

it will hide my window, hence my file

I want to open a file without making it visible, the save it again.
But, if Word is open, it will make the taskbar jump - as I add a new
window all the time.
So, I am looking for a way too Documents.Add(unknown parameters, false
= invisible)
But I dont have any help on what it possible.

I want to open the file, hidden, change it, and save it, so the user
does not see any flicker.

WBR
Sonnich
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top