vba courses london - opening word doc excel

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft VBA Training and help » vba courses london - Opening a word doc from excel using %USERPROFILE% | VBA forum

vba courses london - Opening a word doc from excel using %USERPROFILE% | VBA forum

resolvedResolved · Low Priority · Version Standard

Julian has attended:
Excel VBA Intro Intermediate course

Opening a word doc from excel using %USERPROFILE%

Good day to you,
I distribute an exe program every now and then that puts excel & word files into the C: . However we have recently had our administration rights removed. I am however allowed to distribute this into ?CorD?:\Documents and Settings\?persons name?\My Documents .

My excel macro used to read:
Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
wrdApp.Documents.Add Template:="C:\Pricing Program\30XA autoquote.dot"
wrdApp.Documents(1).Fields.Update
I tried
Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
wrdApp.Documents.Add Template:="%USERPROFILE%\30XA autoquote.dot"
wrdApp.Documents(1).Fields.Update

It sadly doesn't recognise ":="%USERPROFILE%\30XA autoquote.dot" ....have you any ideas.

All the best
Julian


RE: opening a word doc from excel using %USERPROFILE%

Hi Julian

Thanks for your enquiry. It sounds like it might be more helpful to have a conversation with you regarding how you are using the code in your environment, especially as the permissions have changed recently.

I will contact you directly to see if this is something that would be helpful.

Kind regards,

Andrew

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

VBA tip:

Count the Rows and Columns in a Selection

If you need to count the number of rows or columns in a worksheet use the following code:

Selection.Rows.Count - Returns the number of rows in the selection

Selection.Columns.Count - Returns the number of columns in the selection

Selection.CurrentRegion.Rows.Count - Returns the number of rows in the current region of the selection

View all VBA hints and tips


Server loaded in 0.07 secs.