[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

02/26/2009 at 09:07AM PST, ID: 24180767
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.6

VBA Open New Word Document from Template

Asked by accitx in Microsoft Excel Spreadsheet Software, Microsoft Office Suite, Microsoft Word

Tags: VBA Excel and Word

Well i am totally lost with this piece of code and have to turn to you experts to figure out what i am doing wrong or if what I want is even possible.

I have an excel workbook that has VBA code to open a word template, which is not opening it the way you would expect a template file to be opened. Typically when you open a template file it opens a copy of that file as a new file which does not appear to be happening.  The template is located on the network not the users template folder, which shouldnt matter, excel does not seem to have this problem.

The second problem i am having is that i want the intial open of the file to save it to a new location or same location as to where the excel file calling the macro is stored, however it always seems to save it in the users My Documents.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
Sub CreateEstimate()
 
pName = Sheets("Bid Sheet").Range("B1")
pLocation = Sheets("Bid Sheet").Range("B2")
EDate = Format(Now(), "dddd, mmmm dd , yyyy")
eNumber = Format(Now(), "mmddyyhhmmss")
eAmount = FormatCurrency(Sheets("Bid Sheet").Range("E71"), 2)
 
vMyEstimateWording = "j:\" & Year(Now()) & "\" & pLocation & " -" & pName & "\1 - Bid Sheet\Bid Day\"
 
Set wordapp = CreateObject("Word.Application")
Set worddoc = wordapp.Documents.Open("J:\Estimate System\Word Estimate.dotm")
    wordapp.Visible = True
 
With worddoc
    .Bookmarks("pName").Range.InsertAfter pName
    .Bookmarks("pLocation").Range.InsertAfter pLocation
    .Bookmarks("eDate").Range.InsertAfter EDate
    .Bookmarks("eNumber").Range.InsertAfter eNumber
    .Bookmarks("eAmount").Range.InsertAfter eAmount
    .SaveAs pName & "-" & pLocation & "-" & eNumber & ".docm"
End With
 
'worddoc.Save
 
End Sub
 
 
':WORD VBA HERE
Sub EMailPDFCopy()
    Dim vFullName As String
    Dim vPath As String
    Dim vSubject As String
    Dim vBody As String
    Dim vName As String
    Dim bStarted As Boolean
    Dim vSplitTest As Variant
 
    'Dim oOutlookApp As Outlook.Application
    'Dim oItem As Outlook.MailItem
 
    On Error Resume Next
        
    vFullName = Application.ActiveDocument.FullName
    vName = Left(Application.ActiveDocument.Name, Len(Application.ActiveDocument.Name) - 5)
    vSplitTest = Split(vName, "-")
    vPath = Application.ActiveDocument.Path
    vNewName = Left(Application.ActiveDocument.FullName, Len(Application.ActiveDocument.FullName) - 4) & "PDF"
    vSubject = "ESTIMATE - JOB NAME: " & vSplitTest(0) & "  ADDRESS:  " & vSplitTest(1) & "  ESTIMATE #:  " & vSplitTest(2)
    vBody = "Thank you for giving us the opportunity to bid this project.  " & _
                "Please let us know if there is anything else you may need.  " & vbNewLine & _
                "Also keep in mind that we are very aggressive and have the" & _
                " ability to offer voluntary alternates or even design build options to reduce costs.  " & _
                "Most our Voluntary Alternates can be provided in less than 48 hours."
    vSignature = vbNewLine & vbNewLine & "Thank You," & vbNewLine & "ACCI" & vbNewLine & vbNewLine & _
                    "Main: (512) 692-4778 Option 2" & vbNewLine & _
                    "Toll Free: (877) 8AC-CITX (22-2489) Option 2" & vbNewLine & _
                    "Fax: (512) 266-7128" & vbNewLine & "E -Mail: Ron@ accitx.com" & vbNewLine & _
                    "WEB: http://www.accitx.com"
    
    'ChangeFileOpenDirectory vPath
        
    Application.ActiveDocument.Save
    
    ActiveDocument.ExportAsFixedFormat OutputFileName:= _
        vNewName, ExportFormat:=wdExportFormatPDF, OpenAfterExport:=False, OptimizeFor:= _
        wdExportOptimizeForPrint, Range:=wdExportAllDocument, From:=1, To:=1, _
        Item:=wdExportDocumentContent, IncludeDocProps:=True, KeepIRM:=True, _
        CreateBookmarks:=wdExportCreateNoBookmarks, DocStructureTags:=True, _
        BitmapMissingFonts:=True, UseISO19005_1:=False
 
    If Len(ActiveDocument.Path) = 0 Then
        MsgBox "Document needs to be saved first"
        Exit Sub
    End If
 
    Set oOutlookApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then
        Set oOutlookApp = CreateObject("Outlook.Application")
        bStarted = True
    End If
 
    Set oItem = oOutlookApp.CreateItem(olMailItem)
 
    With oItem
        .To = ""
        .Subject = vSubject
        '.GetInspector ' Dont think this is needed or maybe i am not using the correct syntax.
        .Body = vBody & vSignature
        .Attachments.Add vNewName
        .Display
    End With
 
    If bStarted Then
        oOutlookApp.Quit
    End If
 
    Set oItem = Nothing
    Set oOutlookApp = Nothing
 
End Sub
[+][-]02/26/09 09:13 AM, ID: 23746945

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Excel Spreadsheet Software, Microsoft Office Suite, Microsoft Word
Tags: VBA Excel and Word
Sign Up Now!
Solution Provided By: matthewspatrick
Participating Experts: 2
Solution Grade: A
 
 
[+][-]02/26/09 09:15 AM, ID: 23746958

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/26/09 09:31 AM, ID: 23747154

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/26/09 09:34 AM, ID: 23747190

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/26/09 09:41 AM, ID: 23747271

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/26/09 10:42 AM, ID: 23747978

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]02/26/09 11:01 AM, ID: 23748177

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]02/26/09 01:37 PM, ID: 23750152

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]03/06/09 06:12 AM, ID: 23816633

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-91 - Hierarchy / EE_QW_3_20080625