Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Moving To Office 2007 Broke VBA Macro

Status
Not open for further replies.

mark1110

Programmer
Apr 20, 2005
85
0
0
US
Hi,

I have users who are currently using Office 2003. I have a line of VBA code that gets the current network path of a file:

BASICDIR$ = WordBasic.[FileNameInfo$](WordBasic.[MacroFileName$](), 5)

In Office 2003 this give me something like:

\\Ac0gant053\Contract\Production\Winword\

However in Office 2007 I get this:

C:\Documents and Settings\SNMSA5\Local Settings\Temporary Internet Files\Content.MSO\

I have searched the Microsoft site and the internet but I can't find out why this is happening. Can anyone help me out.


Thanks,

Mark

 
>I have a line of VBA code

Well, only sort of ... really it is WordBasic, which was replaced 14 years ago by VBA. Yes, I know that there remain some functions that WordBasic does 'better' than VBA (sorting arrays, for example)

>gets the current network path of a file

Again, only sort of. It theoretically gets the path of the file containing the named macro - which might be the document, or might be a template.

What are you really trying to achieve?
 
The template is located in the \\Ac0gant053\Contract\Production\Winword\ directory, so I am trying to get the network path of the template. What I am getting is something in my documents and settings directory which looks like a temporary copy of the template word put there.
 
What I ended up doing is writing the following code to get the network path to the open document:

Dim oDoc As Document

For Each oDoc In Documents
If InStr(1, UCase(oDoc.Name), "MYDOCUMENT") > 0 Then
sPath = oDoc.Path + "\"
Exit For
End If
Next

Since MyDocument.doc is the open document, the code

oDoc.Path

gives me the network path to the open document



 
Hence my questions about what you were trying to achieve.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top