Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.word.vba.userforms
|
|||
|
|||
![]()
I tried writing code to add \*MERGEFORMAT with the previous VBA syntex
you wrote me, but it would not work. I kept getting a run-time error '450': wrong number of arguments or invalid property assignment. I get this error even when I change rng to Wdoc.Application.Selection, where Wdoc = Wapp.ActiveDocument. Or when I add preserveformat = true. This is the code I wrote: rng.Fields.Add Range:=Selection.Range, Type:=xlWorksheet, _ Text:="LINK Excel.Sheet.8 C:\\Documents and Settings\\shornbec\\Desktop\\sarah\\excel templates\\Mission.FY07Q1_Sarah.xls MissionTimelineDeltaVBudgetTable \a \f 4 \h \*MERGEFORMAT" The Type argument is wrong; you don't need it since the LINK field name is specified in the text. Remove it completely or use wdApp.wdFieldEmpty (where wdApp is whatever variable name you're using for the Word.Application). And put a space between \* and Mergeformat. You'll probably also need to put the path in 'single quotes' since it contains spaces. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#2
![]()
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.word.vba.userforms
|
|||
|
|||
![]()
Hi Cindy-
I tried doing what you said and that didn't seem to work. It wouldn't accept the type:= Wapp.wdFieldEmpty so I replaced it with type:= wdLinkTypeText. I tried several other versions and it still wouldn't work. I was getting the same error. The other things I tried we remove type argument, remove preserveformatting argument, remove both type and preserveformatting argument, and remove range argument. The last piece of code I tried was: rng.Fields.Add Range:=Selection.Range, Type:=wdLinkTypeText, _ Text:="LINK Excel.Sheet.8 'C:\\Documents and Settings\\shornbec\\Desktop\\sarah\\excel templates\\Mission.FY07Q1_Sarah.xls' 'MissionTimelineDeltaVBudgetTable' \a \f 4 \h \* MERGEFORMAT", PreserveFormatting:=True I am really stuck with this. I pasted the rest of my incase you needed it. Thank you for your help! ******************** Private Sub create_report() Dim filename As String Dim Wapp As Word.Application Dim Wdoc As Word.Document Dim dobj As New DataObject Set Wapp = CreateObject("Word.Application") Wapp.Visible = True Wapp.Documents.Add Set Wdoc = Wapp.ActiveDocument Set rng = Wdoc.Paragraphs.Last.Range rng.ListFormat.ApplyListTemplate Wdoc.Application.ListGalleries( _ wdOutlineNumberGallery).ListTemplates(5), ContinuePreviousList:=False, _ ApplyTo:=wdListApplyToWholeList, DefaultListBehavior:=wdWord9ListBehavior rng.Style = "Title" rng.InsertAfter "Contents" rng.InsertParagraphAfter Set rng = Wdoc.Paragraphs.Last.Range rng.Style = "Normal" Set rng = Wdoc.Paragraphs.Last.Range With Wdoc.Application.ActiveDocument .TablesOfContents.Add Range:=rng, RightAlignPageNumbers:=True, _ UseHeadingStyles:=True, UpperHeadingLevel:=2, _ LowerHeadingLevel:=4, IncludePageNumbers:=True .TablesOfContents(1).TabLeader = wdTabLeaderDots .TablesOfContents.Format = wdIndexIndent End With rng.InsertParagraphAfter Set rng = Wdoc.Paragraphs.Last.Range rng.InsertBreak Type:=wdSectionBreakNextPage Dim rng As Word.Range Dim xlMissionDesign As Excel.Workbook Dim x As Integer ThisWorkbook.Activate Worksheets("more options").Activate x = Worksheets("more options").Range("A1") y = Worksheets("more options").Range("A2") Call UseFileDialogOpen Set rng = Wdoc.Paragraphs.Last.Range rng.Style = "Heading 1" rng.InsertAfter "Mission Design" rng.InsertParagraphAfter Workbooks("Mission.FY07Q1_Sarah.xls").Activate For i = 1 To x Set rng = Wdoc.Paragraphs.Last.Range rng.Style = "Heading 3" rng.Font.Underline = wdUnderlineSingle rng.InsertAfter "Option" & " " & i rng.InsertParagraphAfter For j = 1 To y Set rng = Wdoc.Paragraphs.Last.Range rng.Style = "Heading 4" rng.Font.Bold = False rng.Font.Name = "Arial" rng.Font.Size = 12 rng.InsertAfter "Flight Element" & " " & j rng.InsertParagraphAfter Set rng = Wdoc.Paragraphs.Last.Range rng.Style = "List Bullet" rng.InsertAfter "max DLA" rng.ListFormat.ListIndent rng.InsertParagraphAfter Set rng = Wdoc.Paragraphs.Last.Range rng.Style = "Normal" Worksheets("Report Tables Delta V").Activate Worksheets("Report Tables Delta V").Range("MissionTimelineDeltaVBudgetTable").Sele ct Workbooks.Application.CutCopyMode = False Workbooks.Application.Selection.Copy rng.InsertParagraphAfter Set rng = Wdoc.Paragraphs.Last.Range 'rng.PasteExcelTable linkedtoexcel:=True, wordformatting:=False, RTF:=False ' rng.Tables(1).Rows.Alignment = wdAlignRowCenter 'rng.Tables(1).AllowAutoFit = True 'rng.Tables(1).AutoFitBehavior wdAutoFitContent rng.Fields.Add Range:=Selection.Range, Type:=wdLinkTypeText, _ Text:="LINK Excel.Sheet.8 'C:\\Documents and Settings\\sbec\\Desktop\\sarah\\excel templates\\Mission_Sarah.xls' 'MissionTable' \a \f 4 \h \* MERGEFORMAT", PreserveFormatting:=True Next j Next i end sub Cindy M. wrote: I tried writing code to add \*MERGEFORMAT with the previous VBA syntex you wrote me, but it would not work. I kept getting a run-time error '450': wrong number of arguments or invalid property assignment. I get this error even when I change rng to Wdoc.Application.Selection, where Wdoc = Wapp.ActiveDocument. Or when I add preserveformat = true. This is the code I wrote: rng.Fields.Add Range:=Selection.Range, Type:=xlWorksheet, _ Text:="LINK Excel.Sheet.8 C:\\Documents and Settings\\shornbec\\Desktop\\sarah\\excel templates\\Mission.FY07Q1_Sarah.xls MissionTimelineDeltaVBudgetTable \a \f 4 \h \*MERGEFORMAT" The Type argument is wrong; you don't need it since the LINK field name is specified in the text. Remove it completely or use wdApp.wdFieldEmpty (where wdApp is whatever variable name you're using for the Word.Application). And put a space between \* and Mergeformat. You'll probably also need to put the path in 'single quotes' since it contains spaces. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#3
![]()
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.word.vba.userforms
|
|||
|
|||
![]()
I tried doing what you said and that didn't seem to work. It wouldn't
accept the type:= Wapp.wdFieldEmpty so I replaced it with type:= wdLinkTypeText. I tried several other versions and it still wouldn't work. I was getting the same error. The other things I tried we remove type argument, remove preserveformatting argument, remove both type and preserveformatting argument, and remove range argument. The last piece of code I tried was: rng.Fields.Add Range:=Selection.Range, Type:=wdLinkTypeText, _ Text:="LINK Excel.Sheet.8 'C:\\Documents and Settings\\shornbec\\Desktop\\sarah\\excel templates\\Mission.FY07Q1_Sarah.xls' 'MissionTimelineDeltaVBudgetTable' \a \f 4 \h \* MERGEFORMAT", PreserveFormatting:=True If you include the Type argument, then you have to leave out the word LINK in the Text argument. If you set PreserveFormatting:=True, then you should leave \* MergeFormat out of the Text argument. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#4
![]()
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.word.vba.userforms
|
|||
|
|||
![]()
Thank you Cindy that helped alot! Thanks for sticking with me. I
wanted to ask you another question if you don't mind. Do you know how to bookmark a link field. I want to add a bookmark to a table, but everytime I update my table links, the bookmark goes away. It was suggested to me to bookmark the link field, but I do not know how to do this. Do you have any suggestions or know where to point me? Is there another method you would suggest for maintaining the bookmark with a table link updates? Thanks again for all you help. Sarah I had another question that related Cindy M. wrote: I tried doing what you said and that didn't seem to work. It wouldn't accept the type:= Wapp.wdFieldEmpty so I replaced it with type:= wdLinkTypeText. I tried several other versions and it still wouldn't work. I was getting the same error. The other things I tried we remove type argument, remove preserveformatting argument, remove both type and preserveformatting argument, and remove range argument. The last piece of code I tried was: rng.Fields.Add Range:=Selection.Range, Type:=wdLinkTypeText, _ Text:="LINK Excel.Sheet.8 'C:\\Documents and Settings\\shornbec\\Desktop\\sarah\\excel templates\\Mission.FY07Q1_Sarah.xls' 'MissionTimelineDeltaVBudgetTable' \a \f 4 \h \* MERGEFORMAT", PreserveFormatting:=True If you include the Type argument, then you have to leave out the word LINK in the Text argument. If you set PreserveFormatting:=True, then you should leave \* MergeFormat out of the Text argument. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
#5
![]()
Posted to microsoft.public.word.vba.general,microsoft.public.excel.programming,microsoft.public.excel.misc,microsoft.public.word.vba.userforms
|
|||
|
|||
![]()
Hi Hornbecky83,
Thanks for sticking with me. I wanted to ask you another question if you don't mind. Do you know how to bookmark a link field. I want to add a bookmark to a table, but everytime I update my table links, the bookmark goes away. It was suggested to me to bookmark the link field, but I do not know how to do this. Do you have any suggestions or know where to point me? Is there another method you would suggest for maintaining the bookmark with a table link updates? I peripherally followed your discussion about that, but since I basically agreed with what "macropod" told you, I didn't jump in there... You should be able to see the LINK field if you press Alt+F9. You'll need to select a paragraph above (and also maybe below) the field in order to create a bookmark that updating the field won't delete. Cindy Meister INTER-Solutions, Switzerland http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005) http://www.word.mvps.org This reply is posted in the Newsgroup; please post any follow question or reply in the newsgroup and not by e-mail :-) |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Create a Word Table from a Excel Macro | Excel Discussion (Misc queries) | |||
Macro to Extract Text From Word Table Into Excel? | Excel Discussion (Misc queries) | |||
Paste Table from Word in Excel - 2000 -vs- 2002 | Excel Discussion (Misc queries) | |||
Extract MS Excel Data embedded in MS Word | Excel Discussion (Misc queries) | |||
TRYING TO SET UP EXCEL SPREADSHEET ON MY COMPUTER | New Users to Excel |