Utilizzando la macro VBA per creare una parola doc quindi eseguire la macro in word doc … si blocca excel sul sub end

Creo una proposta di vendita dai dati inseriti in un foglio di calcolo di Excel utilizzando una macro, quindi invito una macro per importre alcune immagini "a magazzino" a seconda dei dati inseriti nel foglio di calcolo. Questa seconda macro viene salvata nel documento normal.dot e chiamata dal seguente codice:

WordObj.Run ("normale! Immagine") 'questo chiama una macro in Word che funziona e debug perfettamente

fine sub

Quando la macro finisce e dà il messaggio finale che indica che il documento è terminato correttamente e va al "sub end" nella macro di Word, ottengo un messaggio di errore che indica che Excel si è schiantato e deve essere riavviato!

Queste macro sono state create nel 2002 e hanno lavorato in tutte le versioni di Office, ma stiamo cominciando ad aggiornare a Office 2010 e adesso quando eseguo questa macro, blocchi Excel (solo su client di Office 2010).

Sopprimere i messaggi, ma qui è un messaggio correlato che ottengo se non suppongo errori:

"Microsoft Excel sta aspettando un'altra applicazione per completare l'azione OLE", ma credo che questo accada quando sta cercando di aprire WORD.

Nella mia esperienza di VBA limitata, penso che l'attenzione deve essere restituita alla macro in Excel in modo che possa terminare il suo process appropriato. Penso che la macro di Word si sta completando correttamente, ma non lasciando che l'ultimo "end sub" sia eseguito nella macro di Excel. Tuttavia non riesco a capire come posizionare l'attenzione nella macro di Excel.

Controllerò regolarmente la mia email e lavorerò diligentemente su questo. Se capisco una soluzione, lo pubblicherò immediatamente.

Macro di Excel:

Sub Proposal1() Dim appwd As Object Dim bookmark1 As String Dim test As String Dim ans As String Dim company As String Dim goOn As Integer company = Range("survey!D1") goOn = MsgBox(prompt:="Do you want to create a proposal for " & company & " at this time?", _ Buttons:=vbYesNo) If goOn = vbNo Then Exit Sub Application.DisplayAlerts = False ActiveWorkbook.SaveAs Filename:="c:\sales\salescalc.xls" Application.DisplayAlerts = True Static WordObj As Word.Application Set WordObj = Nothing Set WordObj = CreateObject("Word.Application") WordObj.Visible = True With WordObj .Documents.Add Template:=("C:\sales\sales\proposal1.dot") On Error Resume Next 'Bunch of logic here that reads cells and inputs text to word doc' 'about 150 lines of code all runs normal' End With End Sub 

MACRO DI WORD:

 Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Dim oExcel come object Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Dim doc Come Word.Document Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Dim myfolder come string Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Dim foldername come String Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Impostare fs = CreateObject ("Scripting.FileSystemObject") Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Impostare oExcel = GetObject (, "Excel.Application") Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub oExcel.Visible = Vero Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub Fine con Sub picture() Dim oExcel As Object Dim oWorkbook As Object Dim oWorkSheet As Object Dim verbiage As String Dim doc As Word.Document Dim bkmname As String Dim bkname2 As String Dim bkname3 As String Dim verbiage2 As String Dim verbiage3 As String Dim spec1 As InlineShape Dim spec2 As InlineShape Dim spec3 As InlineShape Dim pic1 As InlineShape Dim pic2 As InlineShape Dim pic3 As InlineShape Dim pic4 As InlineShape Dim pic5 As InlineShape Dim vpic1 As String Dim company As String Dim myfolder As String Dim foldername As String Set fs = CreateObject("Scripting.FileSystemObject") Set oExcel = GetObject(, "Excel.Application") oExcel.Visible = True Set oWorkbook = oExcel.Workbooks.Open("c:\sales\salescalc.xls") Set oWorkSheet = oWorkbook.Sheets("survey") bkmname = "SO1" bkmname2 = "SO2" bkmname3 = "SO3" vpic1 = "pic1" company = oWorkSheet.Range("d1").Value myfolder = "C:\proposals\" Set doc = ActiveDocument If oWorkSheet.Range("b15").Value > 0 Then Set pic1 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic1.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic1").Range) With pic1 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b16").Value > 0 Then Set pic2 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic2.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic2").Range) With pic2 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b17").Value > 0 Then Set pic3 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic3.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic3").Range) With pic3 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b18").Value > 0 Then Set pic4 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic4.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic4").Range) With pic4 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If If oWorkSheet.Range("b19").Value > 0 Then Set pic5 = Selection.InlineShapes.AddPicture(FileName:= _ myfolder & company & "\pics\pic5.jpg" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks("pic5").Range) With pic5 .Width = InchesToPoints(2.46) .Height = InchesToPoints(1.69) End With End If Set doc = ActiveDocument If oWorkSheet.Range("b7") > 0 Then verbiage = oWorkSheet.Range("H27").Value Set spec1 = Selection.InlineShapes.AddPicture(FileName:="c:\sales\spec\" & verbiage & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname).Range) With spec1 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b8") > 0 Then verbiage2 = oWorkSheet.Range("H28").Value Set spec2 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage2 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname2).Range) With spec2 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If If oWorkSheet.Range("b9") > 0 Then verbiage3 = oWorkSheet.Range("H29").Value Set spec3 = Selection.InlineShapes.AddPicture(FileName:= _ "C:\sales\spec\" & verbiage3 & ".gif" _ , linktofile:=False, savewithdocument:=True, Range:=doc.Bookmarks(bkmname3).Range) With spec3 .Width = InchesToPoints(4.17) .Height = InchesToPoints(2.83) End With End If ActiveDocument.SaveAs FileName:=("c:\proposals\" & company & "\" & company & ".doc") MsgBox "A new company proposal for " & company & " has been created" End Sub 

Se è in crash su End Sub è probabilmente correlato alla distruzione di oggetti. Assicurati di distruggere manualmente gli oggetti prima che il codice venga espulso. Questo vi darà un'idea di esattamente quale object è in crash del codice.

Non uso due diversi MACROS quando codifica tra le applicazioni. È ansible dire a Word (o excel) di eseguire l'altro.

Posiziona tutto il codice all'interno di una sola macro in un'applicazione. Ad esempio, l'eccellenza fa roba e poi apre la parola. Così hanno eccellente dire parola che cosa fare direttamente.

 Sub test() Dim wdApp As New Word.Application wdApp.Visible = True wdApp.Documents.Add wdApp.ActiveDocument.Paragraphs(1).Range.Text = "Hello World" End Sub Dim wdApp come nuovo Word.Application Sub test() Dim wdApp As New Word.Application wdApp.Visible = True wdApp.Documents.Add wdApp.ActiveDocument.Paragraphs(1).Range.Text = "Hello World" End Sub 

Facendo riferimento alla libreria corretta (libreria di oggetti Microsoft Word 14.0 per il 2010 e la libreria di oggetti di Microsoft Word 15.0 per il 2013) è ansible distinguere cosa fare all'interno del documento di parola come mostra il mio esempio.

Generalmente, questo è facile come copiare e incollare il codice e quindi albind la parte per parola in una dichiarazione con:

 with wdAPP 'All your word specific code here (might need to add a '.' before each command end with 

Un altro problema che ho trovato con il tentativo di call macro da un'altra applicazione è che è difficile sapere se la macro esiste dall'altro lato. Forse un utente li ha installati in modo non corretto (le mie macro sono distribuite a ~ 300 persone)